Syntax error

G

Guest

I have a report that prints an order based on a unique order number. The
query behind the report obtains the order number from a text box on a
criteria form. I want this text box to be filled in two ways. The first way
is to update a combo box on the criteria form by entering a date range and
filling yhe text box with the selection from the combo box (this works fine).
The second way is to fill the text box directly from the order number text
box on the order entry form which works except when I want to generate the
report, i.e. preview/print the order, the following error occurs:
"Syntax error (missing operator) in quey expression 'OrderID ='."

The reason for being able to print the order in two ways is so that the
order information can be keyed in and the order printed latter or printed
immediately after the information is entered directly from the order entry
form.

If anyone can suggest a solution it would be much appreciated.

cheers,
 
G

Guest

G

Guest

Hi Tom,
Thanks for your reply however I am not sure that this will solve the
problem. The order form can be used to enter a new order or edit and
existing order and if I go to an existing order (which is how I have been
testing this) then the error is the same.

Also, excuse my ignorance but what code would you use to save the record
while continuing to display the record in your form, i.e. is there some code
that should be inserted between the first and second lines of the code in
your reply.

Thanks in advance,

Cheers,
 
G

Guest

Hi Paulu,
...if I go to an existing order (which is how I have been testing this) then
the error is the same.

In that case, the OrderID should be available to the record. I made my
suggestion based on your earlier statement, which did not indicate using an
existing record: "...or printed immediately after the information is entered
directly from the order entry form."
Also, excuse my ignorance but what code would you use to save the record
while continuing to display the record in your form, ...

You can use the code I gave you, ie. setting the dirty property to False. I
always test to see if it is dirty first, by using: If Me.Dirty = True Then
... i.e. is there some code that should be inserted between the first and
second lines of the code in your reply.

I'm not sure what you are asking. I was simply suggesting that you want to
make sure that a record is saved (ie. Dirty property = False) before
attempting to print a report that includes that record. Otherwise, your
report may not reflect the latest changes that have been made by editing a
record.


Tom Wickerath
Microsoft Access MVP

http://www.access.qbuilt.com/html/expert_contributors.html
http://www.access.qbuilt.com/html/search.html
__________________________________________
 
G

Guest

Hi Tom,

My apologies for not making myself very clear.

There are two ways to preview/print an order.
1. From Menu (this is working fine)
a. Open the report criteria form from a menu
b. Enter a date range to limit the order number selection list (combo
box)
c. Select an order number from the combo box
d. Text box is filled with the order number selected in the combo box
using the AfterUpdate Event
e. The Query behind the report uses the order number inthe text box as
criteria
f. A command button is used to generate the report.


2. From the Orders form
a. A new order is entered or an existing order retreived in the form
b. A command button opens the report criteria form (same criteria form
as in 1 above)
c. the date range text boxes and combo box are disabled
d. the text box is filled from the Order Number text box on the Orders
form (this works up to this point)
e. the same command button as in 1 above is used to generate the report.
f. Message "Syntax error (missing operator) in query expression 'OrderID
='." appears

The expression in the query design grid criteria for the OrderID field is;
[Forms]![frmOrdersReportCriteria]![txtOrderNumber]

I hope this explains my problem more clearly.

I say again, any help is much appreciated so for any further suggestions
thank you in advance.

Cheers,
 
G

Guest

Hi Paulu,

I'd like to suggest a different method for previewing (or printing) the
report from the Orders form. Your current method, if I understand it
correctly, requires two button clicks; one on the Orders form, and one on the
report criteria form, which the user cannot override, since the date range
text boxes and combo box are disabled. So, my thought is why even present the
user with the criteria form? Instead, use the WhereCondition argument of the
DoCmd.OpenReport method. Here is a mini tutorial on the subject:

How to print only one page of a multipage report
http://www.access.qbuilt.com/html/reports.html#PrintOnePgOfRpt


Tom Wickerath
Microsoft Access MVP

http://www.access.qbuilt.com/html/expert_contributors.html
http://www.access.qbuilt.com/html/search.html
__________________________________________
 
G

Guest

Hi Tom,

Thanks for all your help. I have sorted the problem out. As I find is
often the case I was focusing on a reference to the query which was working
correctly while the problem was with another reference to the same query
which I over looked. It is all working for me now. Thanks again for your
help, once again I have learned something new.

Cheers,
--
paulu


Tom Wickerath said:
Hi Paulu,

I'd like to suggest a different method for previewing (or printing) the
report from the Orders form. Your current method, if I understand it
correctly, requires two button clicks; one on the Orders form, and one on the
report criteria form, which the user cannot override, since the date range
text boxes and combo box are disabled. So, my thought is why even present the
user with the criteria form? Instead, use the WhereCondition argument of the
DoCmd.OpenReport method. Here is a mini tutorial on the subject:

How to print only one page of a multipage report
http://www.access.qbuilt.com/html/reports.html#PrintOnePgOfRpt


Tom Wickerath
Microsoft Access MVP

http://www.access.qbuilt.com/html/expert_contributors.html
http://www.access.qbuilt.com/html/search.html
__________________________________________

paulu said:
Hi Tom,

My apologies for not making myself very clear.

There are two ways to preview/print an order.
1. From Menu (this is working fine)
a. Open the report criteria form from a menu
b. Enter a date range to limit the order number selection list (combo
box)
c. Select an order number from the combo box
d. Text box is filled with the order number selected in the combo box
using the AfterUpdate Event
e. The Query behind the report uses the order number inthe text box as
criteria
f. A command button is used to generate the report.


2. From the Orders form
a. A new order is entered or an existing order retreived in the form
b. A command button opens the report criteria form (same criteria form
as in 1 above)
c. the date range text boxes and combo box are disabled
d. the text box is filled from the Order Number text box on the Orders
form (this works up to this point)
e. the same command button as in 1 above is used to generate the report.
f. Message "Syntax error (missing operator) in query expression 'OrderID
='." appears

The expression in the query design grid criteria for the OrderID field is;
[Forms]![frmOrdersReportCriteria]![txtOrderNumber]

I hope this explains my problem more clearly.

I say again, any help is much appreciated so for any further suggestions
thank you in advance.

Cheers,
 

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