Results 1 to 3 of 3

Thread: SQL Problem with Access

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Jun 2000
    Posts
    19

    Thumbs down

    I've got a question concerning querying an Access DB. When I run the following code, it works fine:

    Dim strSQL As String

    strSQL = "SELECT * FROM Customers WHERE "
    'Code to handle empty text box
    strSQL = strSQL & "UniqueID = " & txtUnique.Text

    That works. However, when I set the string to search a text value (where the ID is a numeric value):

    strSQL = strSQL & "LastName = " & txtLast.Text

    I get a data type mismatch. It puts the debugging program to the connection string that uses strSQL as the adCmdText.
    Any ideas? Is it something I am not doing with quotation marks?

    Thank you.

    FLL

  2. #2
    Fanatic Member Ianpbaker's Avatar
    Join Date
    Mar 2000
    Location
    Hastings
    Posts
    696
    Hi FLL

    Yes you do need quotation marks for strings try replacing you code with

    strSQL = strSQL & "LastName = '" & txtLast.Text & "'"

    That should sort out your problem

    Hope it helps

    Ian
    Yeah, well I'm gonna build my own lunar space lander! With blackjack aaaaannd Hookers! Actually, forget the space lander, and the blackjack. Ahhhh forget the whole thing!

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Jun 2000
    Posts
    19
    Thanks, Lan. I am now searching on string values.
    I appreciate the guidance.

    FLL

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