Results 1 to 5 of 5

Thread: Help with Syntax on db delete using ID (resolved)

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Feb 2004
    Location
    Texas
    Posts
    144

    Help with Syntax on db delete using ID (resolved)

    Hi,
    Can anyone please help me to understand the conversion of this syntax used in the following two scenarios:

    When execute, I get the following error message from the 1st set of code:
    "No value given for one or more required parameters."

    Thanks,

    Phillip

    Code:
    'This code does NOT work
    dim test as string
    test = LTrim(tmpSTR(UBound(tmpSTR)))    ' test = 1
    Set MyRecSet = MyConn.Execute("DELETE * FROM table1 WHERE ID =" & test)
    Code:
    'This code does work
    'dim test as string
    'test = LTrim(tmpSTR(UBound(tmpSTR)))    ' test = 1
    Set MyRecSet = MyConn.Execute("DELETE * FROM table1 WHERE ID =" & "1")
    Last edited by Iat; Sep 8th, 2004 at 03:43 PM.

  2. #2
    Hyperactive Member ARPRINCE's Avatar
    Join Date
    Mar 2003
    Location
    Pinoy in NJ
    Posts
    381
    The reason behind this is because you are getting NO value on this code since the array cell does not exist:

    VB Code:
    1. test = LTrim(tmpSTR(UBound(tmpSTR)))

    If for example your tmpSTR array has the ff. information:
    Code:
    +---+---------+
    | 0 | APPLE   |
    | 1 | BANANA  |
    | 2 | ORANGE  |
    | 3 | GRAPES  |
    +---+---------+
    Your UBound(tempSTR) is equal to 4 since you have 4 data in your array. However, when addressing each array cell, you start with 0 and end with 3.

    tmpSTR(0) = APPLE
    tmpSTR(1) = BANANA
    tmpSTR(2) = ORANGE
    tmpSTR(3) = GRAPES


    Your tmpSTR(UBound(tmpSTR)) is actually tmpSTR(4) which doesn't exist. hence you get the error.

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Feb 2004
    Location
    Texas
    Posts
    144

    Question

    I am sorry I didn't explain that part. the split() function was declared public and used throughout the application. I changed the code this way to better explain my dilemma. Within my application, I can query and add records to the mdb without any problems.

    Code:
    'This does NOT work
    dim test as string
    test = "1"
    Set MyRecSet = MyConn.Execute("DELETE * FROM table1 WHERE ID = " & test)
    Code:
    'This does work
    'dim test as string
    'test = "1"
    Set MyRecSet = MyConn.Execute("DELETE * FROM table1 WHERE ID = " & "1")

  4. #4
    Hyperactive Member ARPRINCE's Avatar
    Join Date
    Mar 2003
    Location
    Pinoy in NJ
    Posts
    381
    Do you get the same error message as with your first post on this revised code?

    VB Code:
    1. 'This does NOT work
    2. dim test as string
    3. test = "1"
    4. Set MyRecSet = MyConn.Execute("DELETE * FROM table1 WHERE ID = " & test)

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Feb 2004
    Location
    Texas
    Posts
    144
    yes thanks.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width