PDA

Click to See Complete Forum and Search --> : Help With SQL !!!!!


paul
Jul 9th, 1999, 05:52 PM
Code:
Private Sub txtHomePhone_KeyPress(KeyAscii As Integer)
If KeyAscii = vbKeyReturn Then
KeyAscii = 0
Dim strSQL As String
strSQL = "SELECT *From Customer Where (HomePhone = txtHomePhone)"


rsOrderInfo!LastName = txtLastName

txtLastName.SetFocus
End If
End Sub


I am Trying to find the match to a home phone number that the user enters and show the results.I have never used SQL and would be thankful for help

Thanks
Paul

------------------

DVint
Jul 10th, 1999, 11:47 AM
From looking at your post, I gather that the problem is that your SQL query does not work. When you put a variable in an SQL string, you have to put it inside single quotes, and to do THAT, you have to put the single qoutes inside regular quotes, otherwise VB sees the first single as meaning Remark.

strSQL = "SELECT * From Customer Where HomePhone = " & "'"txtHomePhone"'"

Try that (as a single line). it should work fine.

BTW, just about everyone stumbles over this the first time, so don't feel bad.
Dave


------------------

Al Smith
Jul 11th, 1999, 02:26 AM
Paul,
The select clause should be Tablename.Field
Try:
"SELECT Customer.* From Customer Where (HomePhone = txtHomePhone)"

Al.