Single record form

G

Guest

Hi,

I need to print information from individual records with some extra text
added.

Is it possible to have a report that is generated from the currently
selected record in a form, some additional text added and then print it.

Alternatively, is it possible to have a button on a form select a record
item from a report to print.

Ron (record newbie).
 
R

Rick B

To create a button to open a report but only for the current record, build a
button with the following code...

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
 
G

Guest

Thanks Rick,

That does the job perfectly.


Regards,
Ron.

Rick B said:
To create a button to open a report but only for the current record, build a
button with the following code...

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




--
Rick B



Ron said:
Hi,

I need to print information from individual records with some extra text
added.

Is it possible to have a report that is generated from the currently
selected record in a form, some additional text added and then print it.

Alternatively, is it possible to have a button on a form select a record
item from a report to print.

Ron (record newbie).
 

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