Results 1 to 3 of 3
  1. #1
    Join Date
    Mar 2004
    Posts
    38

    Question Unanswered: ADO find method takes only numbers? WTF?

    Like everything ( this started as a very simple task and went terribly wrong.
    Im trying to get a key value (string) from a drop down box ([ClientID]), look it up in a table (T_Clients), and get the value of the column PName from the table.

    Dim cnConnect As ADODB.Connection
    Dim rcdRecord As New ADODB.Recordset
    Dim s As String

    Set cnConnect = CurrentProject.Connection
    rcdRecord.Open "T_Clients", cnConnect, adOpenKeyset, adLockOptimistic, adCmdTable
    s = "[Serial] = " & [ClientID]
    rcdRecord.MoveFirst
    rcdRecord.Find s
    If Not rcdRecord.EOF Then
    [PName] = rcdRecord![PName]
    End If
    rcdRecord.Close

    Now - this works fine when [ClientID] is numbers only, but doesnt work when [ClientID] has letters in it.... I get the error: "3001: Arguments are of the wrong type, out of acceptable range etc...etc...".
    Needles to say - [Serial] is STRING.
    Anyone has an idea what did I do wrong?

  2. #2
    Join Date
    Oct 2003
    Posts
    13
    If the key field is numeric what you have (below) is correct.

    s = "[Serial] = " & [ClientID]

    However, if the field is alpha, then the value must be enclosed in quotes (below).

    s = "[Serial] = '" & [ClientID] & "'"

    That's a single quote followed by your double quote and then at the end a single quote enclosed in double quotes.

    Hope this helps.

  3. #3
    Join Date
    Mar 2004
    Posts
    38
    I have nothing else to say but "YOU DA MAN!!!"

Posting Permissions

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