|
-
Jul 17th, 2001, 10:53 AM
#1
Thread Starter
Junior Member
SQL....to few parameters!
Private Sub GetContactInfo()
Dim SQL As String
SQL = "SELECT * From tblTeams WHERE [fldTeamName] = lstteamNames.Text"
Set rs = db.OpenRecordset(SQL) 'this is the highlighted error line
If rs Is Nothing Then Exit Sub
rs.MoveLast
rs.MoveFirst
While Not rs.EOF
txtHCName.Text = rs("fldHCName") & ""
txtHCPhone.Text = rs("fldHCPhone") & ""
rs.MoveNext
Wend
End Sub
If anyone knows a decent site to learn more about SQL...please let me know.
-
Jul 17th, 2001, 11:25 AM
#2
Addicted Member
here
SQL = "SELECT * From tblTeams WHERE [fldTeamName] = '" & lstteamNames.Text & "' "
when using a variable in an SQL statement, you must use ' then " before (and after) concatenating the variable into the string. If this still doesn't work, verify that you've spelled the columns correctly.
-
Jul 17th, 2001, 11:31 AM
#3
Thread Starter
Junior Member
Wow...it worked!
I couldn't find very much in the MSDN on this...unless I am just looking in the wrong area. But where can you recommend for me to learn more about this. I am not sure what the "&" are even for when used that way. My project is going to be full of changing sql's and recordset's. Thanks again for the help
-
Jul 17th, 2001, 03:52 PM
#4
basically the &'s concatenate the string together so:
VB Code:
dim strA as String
dim strB as string
strA="DOG"
strB = strA & "Cat"
strB now contains "DOGCat"
That is basically what jestes example is doing. It is taking strings and adding them together. It is adding the beginning of your SQL, then your text box value, and then it is finishing off your SQL statement.
Hope this helps,
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
|