Creating queries on the fly (Form not working)

D

dcrqueens

Hello All,

I created a form based off of Martin Green's creating queries on the fly but
I am having some trouble. Below is the code I am using for the On Click even
for the OK button of the form:

Private Sub CmdOk_Click()
Dim db As DAO.Database
Dim qdf As DAO.QueryDef
Dim strSQL As String
Set db = CurrentDb
Set qdf = db.QueryDefs("QryCustomerStatusâ€)
strSQL = "SELECT Tbl CustomerDeliveryTracking.* †& _
"FROM Tbl CustomerDeliveryTracking †& _
"WHERE Tbl CustomerDeliveryTracking.Status='" &
Me.CboStatus.Value & "’ †& _
"AND Tbl CustomerDeliveryTracking.Package Received='" &
Me.CboPackageReceived.Value & "’ †& _
"AND Tbl CustomerDeliveryTracking.Products Received='" &
Me.CboProductsReceived.Value & "’ †& _
"ORDER BY Tbl CustomerDeliveryTracking.Status,Tbl
CustmoerDeliveryTracking.Customer Number;â€

When I click the Ok button I get a Compile Syntax error and the following is
highligted

Set qdf = db.QueryDefs("QryCustomerStatusâ€)

I have checked and rechecked my spelling and reviewed how it is set up. I
cannot seem to figure out why it will not work.

Any help would be greatly appreciated.

Thank you,

Dcrqueens
 
D

Dirk Goldgar

dcrqueens said:
Hello All,

I created a form based off of Martin Green's creating queries on the fly
but
I am having some trouble. Below is the code I am using for the On Click
even
for the OK button of the form:

Private Sub CmdOk_Click()
Dim db As DAO.Database
Dim qdf As DAO.QueryDef
Dim strSQL As String
Set db = CurrentDb
Set qdf = db.QueryDefs("QryCustomerStatusâ€)
strSQL = "SELECT Tbl CustomerDeliveryTracking.* †& _
"FROM Tbl CustomerDeliveryTracking †& _
"WHERE Tbl CustomerDeliveryTracking.Status='" &
Me.CboStatus.Value & "’ †& _
"AND Tbl CustomerDeliveryTracking.Package Received='" &
Me.CboPackageReceived.Value & "’ †& _
"AND Tbl CustomerDeliveryTracking.Products Received='" &
Me.CboProductsReceived.Value & "’ †& _
"ORDER BY Tbl CustomerDeliveryTracking.Status,Tbl
CustmoerDeliveryTracking.Customer Number;â€

When I click the Ok button I get a Compile Syntax error and the following
is
highligted

Set qdf = db.QueryDefs("QryCustomerStatusâ€)

I have checked and rechecked my spelling and reviewed how it is set up. I
cannot seem to figure out why it will not work.

Any help would be greatly appreciated.


If you look very closely, you'll see that you have the wrong sort of
quotation mark at the end of QryCustomerStatus. That's some sort of "smart
quote", Chr(148), not the standard double-quote character, Chr(34), that is
required to delimit the string literal. Change the line to:

Set qdf = db.QueryDefs("QryCustomerStatus")
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top