Hi Everyone,
I have a subreport in my database that is based on a query. In order for the report to run properly it has to get a value from a text box on another form. I used [forms]![form_name]![textbox_name] in the criteria in the design view of the query in order to get the value. I have this in my query and it works perfectly however, I now want to work something new into my database. Because of this change the value the query needs to get could be on one of two separate forms. For example if the user chooses to view a quote by Company name the query needs to get the value off the frmCompany form so I'll have to use [forms]![frmCompany]![txtQuoteNo]. If the user wants to view the Quote by Last Name then the query will have to get the value off the frmLastName form so the criteria expression would now have to be [forms]![frmLastName]![txtQuoteNo]. Obviously I can't have both criteria expressions at once.
So here is what I am trying to do, I want to pass a variable to the query instead so I can assign the Quote Number to this variable and then have the query run using the variable instead of the reference to the text box.
Whew! I hope that makes sense to someone out there. I anyone has any advise or suggestions it would be greatly appreciated.
Janet
I have a subreport in my database that is based on a query. In order for the report to run properly it has to get a value from a text box on another form. I used [forms]![form_name]![textbox_name] in the criteria in the design view of the query in order to get the value. I have this in my query and it works perfectly however, I now want to work something new into my database. Because of this change the value the query needs to get could be on one of two separate forms. For example if the user chooses to view a quote by Company name the query needs to get the value off the frmCompany form so I'll have to use [forms]![frmCompany]![txtQuoteNo]. If the user wants to view the Quote by Last Name then the query will have to get the value off the frmLastName form so the criteria expression would now have to be [forms]![frmLastName]![txtQuoteNo]. Obviously I can't have both criteria expressions at once.
So here is what I am trying to do, I want to pass a variable to the query instead so I can assign the Quote Number to this variable and then have the query run using the variable instead of the reference to the text box.
Whew! I hope that makes sense to someone out there. I anyone has any advise or suggestions it would be greatly appreciated.
Janet