Parameter Value

G

Guest

I have to questions.
!) How do I set a parameter value for printing a record? I have a form
that I enter the information on. I want to put a command button on the form
to print the report of the record that I entered the information on. Is
there a way to do this and how would I do it?
2) I also would like the form to open in full screen view is there a way to
do this? I have a switchboard that you click on the form to open it.
Thank you very much.
Jane
 
D

Damon Heron

First, design your report. Under the record source of your report, build a
query with all the fields from the table that holds the data you want to
display in the report. I am hoping you have a unique ID for each record.
In that field (in the Query window of the report) put this criteria:
[forms]![yourformname]![yourIDfield].[value]
Now when you run the report to test, you should get a parameter box
requesting the value of your id field.
Next,
on your form, put a command button and the click event will be:
DoCmd.OpenReport "Your Report Name", acViewPreview
Save the form.

Now when you click on the button, the report will display the data that is
on the form (provided you have the unique ID on the form)

Second question - on the load event of the form, type: docmd.maximize

HTH
Damon
 
G

Guest

Hi Jane,
(1) You could pass the parameter as part of the opening of the report like
this:
docmd.OpenReport "NAME", acViewPreview, , "WHERECONDITION"
or
Update your query to grab the details off the form using
forms!FORMNAME.FIELDNAME

(2) In the report you are opening, have a form open event that has the
following code - docmd.maximize

Hope this helps.

Damian.
 
G

Guest

Jane:

In addition to what the others have given you, one thing you need to ensure
is that the form's current record is saved. Otherwise if it’s a new record
the report won't print it at all because its not yet been inserted into the
underlying table, or if its an existing record any changes you've made to the
data won't be included in the report.

The simplest way to print the current record is to filter the report by
means of the WhereCondition argument of the OpenReport method; you then don't
need a parameter in the report's underlying query, so the code got a button's
Click event would, assuming a numeric primary key named MyID and a report
named MyReport:

Dim strCriteria As String

strCriteria = "[MyID] = " & Me.[MyID]

' ensure current record is saved
RunCommand acCmdSaveRecord

' print report filtered to current record
DoCmd.OpenReport "[MyReport]", WhereCondition:=strCriteria


BTW if the primary key of the table is of text data type rather than a
number data type you'd then need to wrap its value in quotes:

strCriteria = "[MyID] = """ & Me.[MyID] & """"

Ken Sheridan
Stafford, England
 
G

Guest

"so the code got a button's Click event"

That was a typo the spell checker didn't pick up! It should have been:

"so the code for a button's Click event"

Ken
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top