Re: Repeated Parameter Requests
- From: "George Nicholson" <GeorgeNJunk@xxxxxxxxxxx>
- Date: Mon, 20 Aug 2007 14:57:14 -0500
How are reports being run? via a command button? please post the code
"jallen_45" <jallen45@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:D0379B0A-A198-444D-86F7-C02747E45D69@xxxxxxxxxxxxxxxx
Okay that looks like it will fix the problem, but where do I put it and
what
is the line structure (in a new module or macro)? Remember, I'm a novice!
Thanks!
Joe
"George Nicholson" wrote:
- 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
Assuming you are running reports via a command button, make sure you
reset
the variable to zero before you open report. when the variable is zero,
it
will trigger the prompt again:
glngProjectID = 0 '(or next-value-in-list, if you have a loop set up)
Docmd.Openreport "MyReport"
HTH,
"jallen_45" <jallen45@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:0FCB599D-AA02-4344-87DD-A29A105ABA2C@xxxxxxxxxxxxxxxx
Thanks George!
Your technique solved my initial problem, but created another (my
fault, I
should have thought more into the furture).
Here's the new issue: I did everything you said to and I only have to
enter
the ID number once and the report comes up. However, when I close the
report
and run another, the option to enter the ID number is not there because
it
was changed with the first report (the initial zero value is gone). If
I
close Access and reopen and rerun the report, I can change the ID
number.
I forgot to mention that the report displays data for only one account
holder (report card), so I need to be able to run numerous reports in
one
sitting without restarting Access.
Thanks again for your help earlier. Any information on my new question
will
be greatly appreciated!
Joe
"George Nicholson" wrote:
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
- References:
- Re: Repeated Parameter Requests
- From: George Nicholson
- Re: Repeated Parameter Requests
- From: jallen_45
- Re: Repeated Parameter Requests
- From: George Nicholson
- Re: Repeated Parameter Requests
- From: jallen_45
- Re: Repeated Parameter Requests
- Prev by Date: RE: Filter a Report
- Next by Date: Re: Print Avery Labels 4 Up on One Page
- Previous by thread: Re: Repeated Parameter Requests
- Next by thread: Re: Repeated Parameter Requests
- Index(es):
Relevant Pages
|