Re: Repeated Parameter Requests



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


.



Relevant Pages

  • Re: Repeated Parameter Requests
    ... glngProjectID = ... or you set the ID to zero which would cause the prompt to appear the next ... the variable to zero before you open report. ...
    (microsoft.public.access.reports)
  • Re: Repeated Parameter Requests
    ... the ID number once and the report comes up. ... Public glngProjectID as Long ... ' Note: alternatives to a user prompt include: ... It seems that each of the charts require the unique ID number to be ...
    (microsoft.public.access.reports)
  • Re: Repeated Parameter Requests
    ... glngProjectID = ... or you set the ID to zero which would cause the prompt to appear the next ... the variable to zero before you open report. ...
    (microsoft.public.access.reports)
  • Re: Repeated Parameter Requests
    ... "George Nicholson" wrote: ... causing the prompt to appear *every* time the report is opened. ... glngProjectID = ...
    (microsoft.public.access.reports)
  • Re: Repeated Parameter Requests
    ... -Open the report in design view ... causing the prompt to appear *every* time the report is opened. ... glngProjectID = ... report with the desired charts, but I have to enter the unique ID ...
    (microsoft.public.access.reports)