|
-
Aug 17th, 1999, 04:50 AM
#1
Thread Starter
Lively Member
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
-
Aug 17th, 1999, 11:13 AM
#2
Member
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
------------------
-
Aug 18th, 1999, 06:55 PM
#3
Hyperactive Member
You can also tray this syntax:
Code:
strSQL = "SELECT * FROM SearchByphoneNumber WHERE HomePhone = '" & varHomePhone & "'"
Good Look!
Ulises
[This message has been edited by Tonatiuh (edited 08-19-1999).]
-
Aug 18th, 1999, 07:48 PM
#4
New Member
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!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|