Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Access VBA SQL Statement with VBA variables 1

Status
Not open for further replies.

kjv1611

New member
Jul 9, 2003
10,758
US
I have the following code:
Code:
Dim myquery as QueryDefine

Set myquery = CurrentDb.CreateQueryDef([strQueryName], _
 "SELECT A.DNUM, A.[Desk#], A.Name, A.Balance, A.[Due Date], " & _
 "A.[Due Amount], A.[Attorney Information] " & _
 "FROM tblStatusAudit A " & _
 "WHERE (((A.[Team Leader])=strTeamLeader) " & _
 "AND ((A.Status)=strVarItm));")

When run, it is asking me for data for the variable, strTeamLeader. Of course, when I open the newly created query in design view, it shows strTeamLeader in the criteria under [Team Leader].

Does anything catch anyone's eye right off the bat, where I'm just making a el-stupido error? This is just a small piece of the total code running with this module, I can provide any extra info/code as needed.

My system is this: Windows 2000, Office XP, so 2002 versions of all Office software.

Stephen [infinity]
"Jesus saith unto him, I am the way, the truth, and the life:
no man cometh unto the Father, but by me." John 14:6 KJV
 
this line

"WHERE (((A.[Team Leader])=strTeamLeader) " & _

should be

"WHERE (((A.[Team Leader])= ' " & strTeamLeader & "') " & _

..I think.. :D

------------------------
Hit any User to continue
 
That looks right, and I should know that by now, b/c I've made the same stinkin' error a few times already with other sql statements and such.. doh! I'll see if that fixes, and post back. Thanks for the response.

Stephen [infinity]
"Jesus saith unto him, I am the way, the truth, and the life:
no man cometh unto the Father, but by me." John 14:6 KJV
 
Yep, for sure, that was the fix. Thanks a ton!
[SMILE]

Stephen [infinity]
"Jesus saith unto him, I am the way, the truth, and the life:
no man cometh unto the Father, but by me." John 14:6 KJV
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top