criteria for queries

S

Simon

I have a query with a critera for Order number as
[forms]![frmInvoiceNumber]![ordernumber] Or
[forms]![frmAllInvoices]![ordernumber]


The reason why i need this criteria is that it all depends which form i
am on and which ones i want to run the queriy from

When i run this query from frmAllInvoices it brings up a message box
asking me to enter the order number. if i just click ok it then
displayes the correct information as its uses the second part of the
criterai [forms]![frmAllInvoices]![ordernumber]


If there a way to stop it bringing up the message for me to enter the
first critera. I was expecting as i had the OR between it it would only
neeed one bit of data
 
F

fredg

I have a query with a critera for Order number as
[forms]![frmInvoiceNumber]![ordernumber] Or
[forms]![frmAllInvoices]![ordernumber]

The reason why i need this criteria is that it all depends which form i
am on and which ones i want to run the queriy from

When i run this query from frmAllInvoices it brings up a message box
asking me to enter the order number. if i just click ok it then
displayes the correct information as its uses the second part of the
criterai [forms]![frmAllInvoices]![ordernumber]

If there a way to stop it bringing up the message for me to enter the
first critera. I was expecting as i had the OR between it it would only
neeed one bit of data

Create a separate form to enter the parameter value in.
This way you need to just reference that one form in the query
criteria.
You would call it from both of the other forms when you wish to run
the query.

DoCmd.OpenForm "frmCriteriaEntry", , , , , acDialog
DoCmd.OpenQuery "QueryName"
DoCmd.Close acForm, "frmCritiriaEntry"
 
S

Simon

Thanks

I will have a play

Is there any other way of doing it instead of creating another form

Thanks


SImon said:
I have a query with a critera for Order number as
[forms]![frmInvoiceNumber]![ordernumber] Or
[forms]![frmAllInvoices]![ordernumber]

The reason why i need this criteria is that it all depends which form i
am on and which ones i want to run the queriy from

When i run this query from frmAllInvoices it brings up a message box
asking me to enter the order number. if i just click ok it then
displayes the correct information as its uses the second part of the
criterai [forms]![frmAllInvoices]![ordernumber]

If there a way to stop it bringing up the message for me to enter the
first critera. I was expecting as i had the OR between it it would only
neeed one bit of data

Create a separate form to enter the parameter value in.
This way you need to just reference that one form in the query
criteria.
You would call it from both of the other forms when you wish to run
the query.

DoCmd.OpenForm "frmCriteriaEntry", , , , , acDialog
DoCmd.OpenQuery "QueryName"
DoCmd.Close acForm, "frmCritiriaEntry"
 

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