PDA

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


paul
Aug 17th, 1999, 04:50 AM
Private Sub Command1_Click()
Dim strSQL As String
strSQL = "SELECT * FROM SearchByphoneNumber " & _
"WHERE (HomePhone = """ & varHomePhone & """);"
Me.Data1.RecordSource = strSQL
Me.Data1.Refresh
varHomePhone.SelStart = 0
varHomePhone.SelLength = Len(varHomePhone.Text)

End Sub

When I use this code i get an error " Run-Time error '3061' "
Too Few paremeters , expected 1

Thanks for your help

Wesam
Aug 17th, 1999, 11:13 AM
DOUBLE-QUOTES !! .. try using apostrophes, by the way it seems you are using Access-like SQL string;this is not always HEALTHY;

strSQL = "SELECT * FROM SearchByphoneNumber " & _
"WHERE (HomePhone = '" & varHomePhone & "')"

..or
double DOUBLE-QUOTES

strSQL = "SELECT * FROM SearchByphoneNumber " & _
"WHERE (HomePhone = """" & varHomePhone & """");"

Hope this works ..

Wesam


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

Tonatiuh
Aug 18th, 1999, 06:55 PM
You can also tray this syntax:

strSQL = "SELECT * FROM SearchByphoneNumber WHERE HomePhone = '" & varHomePhone & "'"

Good Look!

Ulises

[This message has been edited by Tonatiuh (edited 08-19-1999).]

KentJ
Aug 18th, 1999, 07:48 PM
Paul,
Your original syntax looked ok to me (me being no expert!) Just a few (silly?) comments: 1)It appears that varHomePhone is a text box, if so try varHomePhone.text in the SQL string; 2) if varHomePhone is not a text box make sure it is a _string_ value; 3)Lastly, I have found it helpful to view the SQL string in the immediate pane while stepping through the code. This way you can verify that you're really getting what you want.

Good luck! I've lost many hours of my life troubleshooting SQL statements too!