Problem With SQL String

John Baker

Registered User.
Local time
Today, 14:30
Joined
Apr 13, 2005
Messages
35
Hi All -

Looking for help with debugging an SQL string. I am trying to open a recordset using the following declarations and statements:

Dim db as Database
Dim rs as DAO.Recordset
Dim strBU as String
Dim strCustomerType as String
Dim strSQL as String

strSQL = "SELECT BU, CUSTOMER_TYPE, NUMBERPRGN, ELAPSED " & _
"FROM qry_ims_local " & _
"WHERE qry_ims_local.BU = " & strBU & " " & _
"AND qry_ims_local.CUSTOMER.TYPE = " & strCustomerType

Set rs=db.OpenRecorset(strSQL)


When I try to execute this code, I get a run time error '3061' - Too few parameters. Expected 2.

The query (qry_ims_local) does not have any parameters associated with it. I'm stumped. Any help would be appreciated.

Thanks,
John
 
Found My Problem - Syntax Error

Fixed my problem with the following syntax changes:

strSQL = "SELECT BU, CUSTOMER_TYPE, NUMBERPRGN, ELAPSED " & _
"FROM qry_ims_local " & _
"WHERE qry_ims_local.BU = " & """" & strBU & """" & " " & _
"AND qry_ims_local.CUSTOMER_TYPE = " & """" & strCustomerType & """" & " " & _
"ORDER BY qry_ims_local.ELAPSED"
 
You can also use single quotes...
"WHERE qry_ims_local.BU = '" & strBU & "' " & _
 

Users who are viewing this thread

Back
Top Bottom