The field is actually called UR Number and it's a text field because even
though it's a number, the first number is usually 0 and if it's set up as a
numeric field the 0 won't show. The 0 must be there to keep things the same
across all programs.
I've set up a switchboard that has a button that says "Print". This opens
the report. The report has an "On Open" macro that will open the dialog form
(called PrintDialog). This form has a combo box on it that asks for the UR
Number (if you press the drop down arrow it displays two columns - UR Number
and Patient Name). It also has two command buttons - OK - which is supposed
to open up the report for the UR Number in the combo box. The other button
is cancel - this one doesn't work properly either.
The instructions are in the help menu of Access called "Use a form to enter
report criteria". It says to set up a form with the following properties -
DefaultView: Single Form; ViewsAllowed: Form; ScrollBars: Neither;
RecordSelectors: No; NavigationButtons: No; BorderStyle: Dialog.
It says to use a text box to enter criteria, but I used a combo as described
above with the Name property set to UR Number.
Then it says to set up four macros in a macro group:
Open Dialog - this is the OnOpen procedure for the report - opens the dialog
form
Close Dialog - this is the OnClose procedure for the report - closes the
dialog form
OK - this is attached to the OK button on the dialog form(settings are Item
- [Visible]; Expression - No)
Cancel - attached to the Cancel button on the dialog form
The report is attached to a query with only two fields - UR Number and Name.
In the criteria for UR Number I modified their example of between dates so
that it looked for a UR Number like the one in the combo box.
It all seems to work up until the moment I press OK. The report is filtered
down to one patient - unfortunately it is always the first patient on the
list, not the one selected on the form. Also, when I press the cancel
button, the form closes but then the automatic dialog box for the query is
open.
Thinking about it now, I wonder if I should just forget all that macro stuff
and just use the automatic pop-up box that the query uses - though it would
be nice for the end user to be able to double check they have entered the
right UR Number prior to the report opening (which they can do with the combo
box).
Ken Snell said:
Is PatientID a numeric field? If yes, I'd use an expression that has =
instead of Like.
I am not directly familiar with the "instructions" that you cite, so I'm not
sure where the programming for popping up the dialog box is (in the report?)
UR Number is the name of the control on the form (named "PrintDialog"),
right? And UR Number is bound to the field PatientID on that form? What type
of form is PrintDialog?
I need a little more info about how you set up this dialog box, etc. Can you
tell me where you started in ACCESS and where you've put
code/programming/etc.? And which form or forms are open when you run the
report? And how you run the report (e.g., you click a button on a form named
.....)?
--
Ken Snell
<MS ACCESS MVP>
Thanks Ken for all your help. I don't think it would have ever occurred
to
me to use sub-reports.
There's just one last thing though - with the dialog box to use to filter
the report - I have followed the instructions in Access called "Use a form
to
enter report criteria" to set up the dialog box with the command buttons
and
macros. The instructions say "Enter the criteria for the data. In the
expression, use the Forms object, the name of the form, and the names of
the
controls in the criteria." Then it gives an example. I modified the
example
so that instead of saying between certain dates, I wrote (in the criteria
section of the PatientID field of the query the report is based on):
LIKE [Forms]![PrintDialog]![UR Number]
(UR Number is the name of the field for PatientID)
When I run the report it opens with the dialog box, I select the
appropriate
UR Number, press OK, then an error pops up:
"The expression you entered has a function name that CT Data Management
can't find."
And the report opens for the first patient in the patient list.
How do I fix this??
Thanks
I have linked the "Master Report" to a query that lists all patients and
their ID numbers
:
Comments inline....
--
Ken Snell
<MS ACCESS MVP>
So what I do is:
Set up each subreport as separate reports and then set up a "master"
report
which the separate reports link into as the sub reports. - Is this
right?
Yes.
Set up the dialog form so user can select appropriate patient.
- I'm not quite sure what you mean about the bound column for the
combo
box
though - could you please explain that just a little more?
The bound column of a combo box defines which column in the row source
is
the one from which the combo box draws its value. In the Properties
window,
on the Data tab, you'll see this property. Bound column is one-based,
meaning that 1 is the first column, 2 the second column, etc. (Many
properties are zero-based, meaning that 0 is the first column, 1 is
second
column, etc.). So, if your query returns two fields -- an ID field and a
descriptor field, for example -- you'd likely want the Bound Column to
be 1
so that the ID value is the actual value of the combo box. But you can
display the descriptor field for the user's benefit.
Thanks