SmithVoice
Sep 15th, 1999, 08:19 AM
Up to you but you might want to get in the habit of being more specific in your SQL table mentions (as shown below with full referencing) Also, you don't need to include the final semi-colon. If you make this SQL into querydef without the semicolon you will see that Access adds it in the SQLview (like Access adds the hidden carrage returns between clauses) automatically.
Also up to you but I use chr(34) instead of embedded quotes, this adds typing up front but it also stops most quote related errors.
Um, I'm making the assumption that there is a single table named "[Open Position]" right?
So, try this and let me know if it gets any farther:
dim strSQL as string
dim rs as recordset
strSQL = "SELECT * FROM [Open Positions] " & _
"WHERE ([Open Positions].[HospitalCode] = " & chr(34) & strHospital & chr(34) & _
") AND ([Open Positions].[Division/Unit] = " & chr(34) & strUnit & chr(34) & _
") AND ([Open Positions].[Location] = " & chr(34) & strLocation & chr(34) & _
") AND ([Open Positions].[Job Number] = " & chr(34) & strJob & chr(34) & ")"
set rs = db.openrecordset (strSQL, dbopenforwardonly)
------------------
http://www.smithvoice.com/vbfun.htm
Also up to you but I use chr(34) instead of embedded quotes, this adds typing up front but it also stops most quote related errors.
Um, I'm making the assumption that there is a single table named "[Open Position]" right?
So, try this and let me know if it gets any farther:
dim strSQL as string
dim rs as recordset
strSQL = "SELECT * FROM [Open Positions] " & _
"WHERE ([Open Positions].[HospitalCode] = " & chr(34) & strHospital & chr(34) & _
") AND ([Open Positions].[Division/Unit] = " & chr(34) & strUnit & chr(34) & _
") AND ([Open Positions].[Location] = " & chr(34) & strLocation & chr(34) & _
") AND ([Open Positions].[Job Number] = " & chr(34) & strJob & chr(34) & ")"
set rs = db.openrecordset (strSQL, dbopenforwardonly)
------------------
http://www.smithvoice.com/vbfun.htm