Criteria based on current form

prmitchell

Registered User.
Local time
Tomorrow, 03:18
Joined
Jan 2, 2013
Messages
58
I wish to run the same query from three different forms - where the criteria is the client # on the currently loaded form from which the query will be run.

I can make 3 different queries of course - but is there a way with the same query?

Help always appreciated.
 
1) Remove your client# constraint from the query
2) Make a datasheet Form from the full query
3) Open the form with DoCmd, supplying a filter condition in the call

Now any consumer that knows the ClientNumber can open the query filtered using one line of code ...
Code:
DoCmd.OpenForm "YourForm", , , "ClientNumber = " & Me.ClientNumber
 
Unfortunately I have not quite got what you suggested to work, I have tried to olpen a form called History with

DoCmd.OpenForm "History", , , "[ClientNumber]= " = Me.ClientNumber
but I get an error
Method or data member not found and
.ClientNumber is highlighted
 
You seem to have an superfluous equal sign in your code it should look like;
Code:
DoCmd.OpenForm "History", , , "[ClientNumber]= " Me.ClientNumber

Also does the control ClientNumber exist on the calling form?
 
Re: Opening one form and then another based on values

Apologies for the similar posting on the opening form thread
I have now tried
DoCmd.OpenForm "History", , , "[ClientNumber]= " Me.ClientNumber
I am getting an unexpected end of statement error and the ME highlighted (Access 2010)

I am just not getting the syntax of the double quotes and and what that part of the argument refers to and what the second part of argument refers to

The calling form has ClientNumber as does the form I wish to open (or do I make them different names, will this help me understand more?)
 
Sorry my bad missed the ampersand :( try;
Code:
DoCmd.OpenForm "History", , , "[ClientNumber]= "[B][COLOR="Red"] &[/COLOR][/B] Me.ClientNumber
 

Users who are viewing this thread

Back
Top Bottom