View Single Post
  #3  
Old December 8th, 2009, 06:58 PM posted to microsoft.public.access.queries
Wayne[_13_]
external usenet poster
 
Posts: 19
Default Change Form/Report Query Based on User Selection

On Dec 7, 12:04*pm, John Spencer wrote:
I would say only if you are willing to construct the entire query string in
VBA and then apply that string as the source of the report.

John Spencer
Access MVP 2002-2005, 2007-2009
The Hilltop Institute
University of Maryland Baltimore County



Wayne wrote:
I have a form and report based on a query. *I need to change the query
based on what the user selects on a form. *Using VBA in MS Access
2002, can I change a single field in an existing query from GROUP BY
to LAST? This process would be initiated by a click event on a form.
Thanks in advance for any help.- Hide quoted text -


- Show quoted text -


Thanks. Putting the SQL into a string seems to be the best way to do
it but now I have a new problem.

When I change the query GROUP BY field to LAST in VBA the Control
Source name changes from ServiceFrom to LastOfServiceFrom. On the
form I have tried many ways to display both fields like:

=IIf(IsError([LastOfServiceFrom]), [ServiceFrom],[LastOfServiceFrom])
This displays the [LastOfServiceFrom] correctly but gives an #ERROR
when the query is changed to the [ServiceFrom] field.

=IIf(IsError([ServiceFrom]),[LastOfServiceFrom],[ServiceFrom])
This displays the same as the above???? I thought it would be the
opposite but it’s not. Only the [LastOfServiceFrom] displays
correctly. Weird.

How can I get both field names to display correctly in my form when
the Record Source query is changed?