Call Query from one of two forms?

P

Philip Martin

I have a Report, based on query. The problem is that I need to be able to
call up the query, with a filter on a field (the same field from either
source) from one of two forms. I have tried the following SQL in the WHERE
command line:

WHERE
(((OrdersTbl.PurchaseOrderID)=IIf(IsNull([Forms]![OrdersFrm]![PurchaseOrderI
D]),[Forms]![POSelectorFrm]![Combo0],[Forms]![OrdersFrm]![PurchaseOrderID]))
);

But it doesn't work:eek:(

What I want is to be able to call the query from either source, but not have
the other popup box requesting an input. I have also tried the OR comand
line on the Criteria line, without success.

Any one know how I can do this?

TIA,

Philip Martin.
 
A

Anthony

When you report is generated, are both forms opened? Both forms need to be opened for your report to work as it is programmed.
 
P

Philip Martin

Anthony said:
When you report is generated, are both forms opened? Both forms need to
be opened for your report to work as it is programmed.

At the moment it will 'work' with either form open (one open and one
closed). But when the query is called the 'popup' box from the other
Criteria input comes up. Clicking on OK without inputting any data into this
box will let the query carry on and produce the required data. However I
would like to stop this 'other' box appearing in the first place!

I suppose I could duplicate the query and re-name all the second copies, but
it seems a bit daft when I already have a query performing the required
filter.

Thanks,

Philip Martin.
Philip Martin said:
I have a Report, based on query. The problem is that I need to be able to
call up the query, with a filter on a field (the same field from either
source) from one of two forms. I have tried the following SQL in the WHERE
command line:

WHERE
(((OrdersTbl.PurchaseOrderID)=IIf(IsNull([Forms]![OrdersFrm]![PurchaseOrderI
D]),[Forms]![POSelectorFrm]![Combo0],[Forms]![OrdersFrm]![PurchaseOrderID]))
);

But it doesn't work:eek:(

What I want is to be able to call the query from either source, but not have
the other popup box requesting an input. I have also tried the OR comand
line on the Criteria line, without success.

Any one know how I can do this?

TIA,

Philip Martin.
 
A

Anthony

The "other" box pops up because you need to have both forms opened when your report is being generated. When the form is not open, Access can't get the info from that form, thus giving you the pop up, asking you for input. Access treats unknown names as input variables. You might want to link the critieria direction to a table or a sub query that would reproduce the result of the forms. That way, you won't need a form to be opened to have the info for your report.

I hope this helps.



Philip Martin said:
Anthony said:
When you report is generated, are both forms opened? Both forms need to
be opened for your report to work as it is programmed.

At the moment it will 'work' with either form open (one open and one
closed). But when the query is called the 'popup' box from the other
Criteria input comes up. Clicking on OK without inputting any data into this
box will let the query carry on and produce the required data. However I
would like to stop this 'other' box appearing in the first place!

I suppose I could duplicate the query and re-name all the second copies, but
it seems a bit daft when I already have a query performing the required
filter.

Thanks,

Philip Martin.
Philip Martin said:
I have a Report, based on query. The problem is that I need to be able to
call up the query, with a filter on a field (the same field from either
source) from one of two forms. I have tried the following SQL in the WHERE
command line:

WHERE
(((OrdersTbl.PurchaseOrderID)=IIf(IsNull([Forms]![OrdersFrm]![PurchaseOrderI
D]),[Forms]![POSelectorFrm]![Combo0],[Forms]![OrdersFrm]![PurchaseOrderID]))
);

But it doesn't work:eek:(

What I want is to be able to call the query from either source, but not have
the other popup box requesting an input. I have also tried the OR comand
line on the Criteria line, without success.

Any one know how I can do this?

TIA,

Philip Martin.
 
P

Philip Martin

Anthony said:
The "other" box pops up because you need to have both forms opened when
your report is being generated. When the form is not open, Access can't get
the info from that form, thus giving you the pop up, asking you for input.
Access treats unknown names as input variables. You might want to link the
critieria direction to a table or a sub query that would reproduce the
result of the forms. That way, you won't need a form to be opened to have
the info for your report.
I hope this helps.
Of course, that'll work nicely:eek:)

Many thanks,

Philip martin.
 
Top