How to print 1 record on Access form w/scrollable fields expanded

C

Capt Jim Cook

I want to create a [Print] button that prints only the current record on the
Access form. The form has scrollable Memo fields which need to expand (if
necessary) to show all text in the data element.
Thanks.
 
R

Rick B

You should not print a form. Forms are user interfaces designed to enter
and view data. Reports are designed for printing.

Create a report that includes the data you want laid out in the appropriate
format.

Then, add a button to your form to print that report. You can also specify
that it only print the current record.

The code in your button would be something like the following:


Private Sub cmdPrint_Click()

Dim strWhere As String

If Me.Dirty Then 'Save any edits.

Me.Dirty = False

End If

If Me.NewRecord Then 'Check there is a record to print

MsgBox "Select a record to print"

Else

strWhere = "[ID] = " & Me.[ID]

DoCmd.OpenReport "MyReport", acViewPreview, , strWhere

End If

End Sub



Notes: If your primary key is a Text type field (not a Number type field),
you need extra quotes: strWhere = "[ID] = """ & Me.[ID] & """"

If you want the report to print without preview, replace acViewPreview with
acViewNormal.



See also: http://allenbrowne.com/casu-15.html
 

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