G
Guest
Yesterday, I asked:
I have a report that would use one of two queries, depending on the status of
a field in the main database table.
The field in the table is called "In-House", and is set as a Yes/No field.
What I want to be able to do, is, upon opening the report, to have it check
that field, and if it is Yes then it would run query1. If it is no, then it
would run query2.
Is there a way to do this?
and was told:
By code you can set recordsource
if In-House = 0 then
reports("YourReport").recordsource = query1
else
reports("YourReport").recordsource = query2
end if
I entered the code in the report open as:
If In_House = 0 Then
DoCmd.OpenReport "testreport2", acViewPreview, "test1"
Else
DoCmd.OpenReport "testreport1", acViewPreview, "test2"
End If
I have the record source for the report set to a query titled 'test' that
has the field In_House in the query. I have a parameter setup that asks me
the "status" of In_House that I want.
Every time that I run it, the report testreport2 is opening.
Any possible suggestions?
However, whenever I run the query
I have a report that would use one of two queries, depending on the status of
a field in the main database table.
The field in the table is called "In-House", and is set as a Yes/No field.
What I want to be able to do, is, upon opening the report, to have it check
that field, and if it is Yes then it would run query1. If it is no, then it
would run query2.
Is there a way to do this?
and was told:
By code you can set recordsource
if In-House = 0 then
reports("YourReport").recordsource = query1
else
reports("YourReport").recordsource = query2
end if
I entered the code in the report open as:
If In_House = 0 Then
DoCmd.OpenReport "testreport2", acViewPreview, "test1"
Else
DoCmd.OpenReport "testreport1", acViewPreview, "test2"
End If
I have the record source for the report set to a query titled 'test' that
has the field In_House in the query. I have a parameter setup that asks me
the "status" of In_House that I want.
Every time that I run it, the report testreport2 is opening.
Any possible suggestions?
However, whenever I run the query