Connecting Tech Pros Worldwide Help | Site Map

Use result from Inputbox in query

Roberta
Guest
 
Posts: n/a
#1: Nov 13 '05
Hello,

When I use the following code to print a report for a certain client,
it works fine:
DoCmd.OpenReport "rpt_MNMTSingleCover_Summary_Recommendations",
acPreview, "", "[qry_MNMTSingleCover_Summary_Recommendations]![strClientID]=[Enter
Client ID]"


But I want to run multiple reports for the same client without asking
for the client ID more than once so I tried the following code:
Dim clientid As String
clientid = InputBox("Enter Client ID")

DoCmd.OpenReport "rpt_MNMTSingleCover_Summary_Recommendations",
acPreview, "", "[qry_MNMTSingleCover_Summary_Recommendations]![strClientID]=clientid"

When I run this code it asks for the client ID OK but after I enter
the ID, I get another window that wants me to enter the parameter
value for clientid.


I would appreciate any help on this.
Thanks
Roberta
rkc
Guest
 
Posts: n/a
#2: Nov 13 '05

re: Use result from Inputbox in query



"Roberta" <rhastin@dhs.state.ia.us> wrote in message
news:cc6b0d09.0406180530.1b52233f@posting.google.c om...[color=blue]
> Hello,
>
> When I use the following code to print a report for a certain client,
> it works fine:
> DoCmd.OpenReport "rpt_MNMTSingleCover_Summary_Recommendations",
> acPreview, "",[/color]
"[qry_MNMTSingleCover_Summary_Recommendations]![strClientID]=[Enter[color=blue]
> Client ID]"
>
>
> But I want to run multiple reports for the same client without asking
> for the client ID more than once so I tried the following code:
> Dim clientid As String
> clientid = InputBox("Enter Client ID")
>
> DoCmd.OpenReport "rpt_MNMTSingleCover_Summary_Recommendations",
> acPreview, "",[/color]
"[qry_MNMTSingleCover_Summary_Recommendations]![strClientID]=clientid"[color=blue]
>
> When I run this code it asks for the client ID OK but after I enter
> the ID, I get another window that wants me to enter the parameter
> value for clientid.[/color]

Save the result of the inputbox to a textbox control on the form and then
reference the textbox control in your Where Condition. An example of
the syntax can be found in help under 'OpenReport Action'.



Roberta
Guest
 
Posts: n/a
#3: Nov 13 '05

re: Use result from Inputbox in query


rkc:

Thank you very much for your prompt response. The code worked great!
Thanks!!!

Roberta
Closed Thread


Similar Microsoft Access / VBA bytes