Printout of open form in landscape format

  • Thread starter Thread starter P
  • Start date Start date
P

P

Hi,

Access 2002. I am trying to use the PrintOut function to print the current
record of the current open form in landscape format to the default Windows
printer. Any suggestion on how to set the printout to landscape mode? Thank
you. P
 
Hi P

Create a report based on your table(s) displaying the fields you want
printed, and format the report exactly how you want it - page orientation,
margins, etc. If the required layout is similar to your form, then you
could start with File>Save As>Report.

Now, place a command button on your form, named cmdPrintCurrentRecord, and
in its Click event procedure put this code:

DoCmd.OpenReport "name of report", _
WhereCondition:="[name of primary key field]=" _
& Me.[Name of primary key field]

If your primary key is a text field, you will need to wrap the value in
quotes:
...
& chr(34) & Me.[Name of primary key field] & chr(34)
 
P said:
Hi,

Access 2002. I am trying to use the PrintOut function to print the current
record of the current open form in landscape format to the default Windows
printer. Any suggestion on how to set the printout to landscape mode? Thank
you. P

PrintOut won't do what you want.

1) A form is for data entry and manipulation, not for printing.

2) Make a report that shows the fields you would like to print.

3) In design view, click:
File + Page SetUp + Page.
Set the report to Landscape.
Save the report.

3) Add a command button to the form.

4) Code the command button click event:
DoCmd.OpenReport "ReportName", acPreview, , "[RecordID] = " &
[RecordID]

The above code assumes your record has a unique prime key field of
Number datatype.
See Access help for how to code different datatypes:
Where clause + Restrict data to a subset of records

The report will display just the record shown on your form.
Change acViewPreview to acViewNormal to print without preview.

5) If for some reason you absolutely must print the record data with the
form as background, on the database window, right-click on the form,
and select 'Save as Report'.

6) Set it to Landscape, as above.

7) Use the same command button code as above to print the report (which
will look like your form).
 
Back
Top