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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Punctuation aggravation

Status
Not open for further replies.

barboza

Programmer
Oct 20, 2007
7
US
It took forever to get the following line to work in VBA:

Set rst = dbs.OpenRecordset("Select [LocationName] from PWS where [LocationNumber] = '" & Me.LocationNumber & "';")


Now I am trying to get the following line of code to run with no success:
Set rst = dbs.OpenRecordset("Select [LocationName] from PWS where [LocationNumber] = '" & Me.LocationNumber And Me.PWSName = PWS.PWSName & "';")

I am having the hardest time figuring out quotes, semicolons etc.. using vba.
No problem just writing the sql statement in sql designer, and running the saved query. Punctuating the sql statement so it will run in VBA has been frustrating to put it mildly. Can anyone write this line of code so it will run in vba.

Can someone point me to a clear and understandable explanation of how punctuation works in vba??

Thanks,

B
 
[tt]Set rst = dbs.OpenRecordset("SELECT LocationName FROM PWS WHERE LocationNumber='" & Me.LocationNumber & "' AND PWSName='" & Me.PWSName & "';")[/tt]

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Perfect. That is exactly what is needed. Thank you so much!!!
Worked like a charm.

I have found the biggest problem I have had is figuring out the punctuation.

Thanks again!!!

B
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top