PDA

Click to See Complete Forum and Search --> : SQL Problem with Access


FLL
Aug 24th, 2000, 08:07 PM
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

Ianpbaker
Aug 25th, 2000, 02:11 AM
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

FLL
Aug 25th, 2000, 07:28 AM
Thanks, Lan. I am now searching on string values.
I appreciate the guidance.

FLL