Re: Repeated Parameter Requests
- From: "George Nicholson" <GeorgeNJunk@xxxxxxxxxxx>
- Date: Fri, 17 Aug 2007 16:06:57 -0500
This is the technique I find myself using most of the time for values I need
to reference over & over again.
It might not be your cup of tea.
- Open the VB editor (F11 or Tools>Macros>VBE)
- Insert>Module
- Copy & paste everything between Start & End Code into the module:
'************ Start Code ****************
Public glngProjectID as Long
Public Function GetProjectID() As Long
On Error GoTo ErrHandler
Do While glngProjectID = 0
' Prompt user for a value
glngProjectID = Clng(InputBox("Please enter a ProjectID"))
' Note: alternatives to a user prompt include:
' reading value from an open form,
' passing an optional value to this function,
' reading a value from a table, etc.
Loop
GetProjectID = glngProjectID
ExitHere:
Exit Function
ErrHandler:
MsgBox("Error in function 'GetProjectID'")
Resume ExitHere
End Function
'************ End Code ****************
-Replace the criteria parameters in your query with:
GetProjectID()
(and the parentheses are necessary)
- you should only be prompted for the ID once per report. After that the
stored value will be used.
- NOTE: that value will *remain* stored until you change it. You can either
change the ID to a new value with:
glngProjectID = (some new value)
or you set the ID to zero which would cause the prompt to appear the next
time the function is called:
glngProjectID = 0
Good places to change/set the value would include the CommandButton_Click
event that runs the report, some AfterUpdate event where the user has
selected a new ProjectID, etc.
Note that you can use GetProjectID() in any query and any code within your
app.
HTH,
"jallen_45" <jallen45@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:E8030A03-BB19-4C2E-9E9C-2109381DE699@xxxxxxxxxxxxxxxx
I created a report from a single query, and then I added two charts to the
report (using the data from the same query as the report). I would like to
enter a unique ID number to get a report with just one organization's data
on
it (as opposed to every organization in the entire database). I get the
report with the desired charts, but I have to enter the unique ID number
five
times! It seems that each of the charts require the unique ID number to be
entered 2 times because the report with out the charts only requires the
ID
number to be enterred once.
What can I do so that I only have to enter the unique ID once and get the
report with both charts? Simple instructions would be great as I am still
quite the novice! Thank you very much in advance!
Joe
.
- Follow-Ups:
- Re: Repeated Parameter Requests
- From: jallen_45
- Re: Repeated Parameter Requests
- From: Mikal via AccessMonster.com
- Re: Repeated Parameter Requests
- Prev by Date: Re: Repeated Parameter Requests
- Next by Date: RE: Fiscal YTD Calculation Not Working Correctly
- Previous by thread: Re: Repeated Parameter Requests
- Next by thread: Re: Repeated Parameter Requests
- Index(es):
Relevant Pages
|