Printing a Current record

Nimrod146

Registered User.
Local time
Today, 00:00
Joined
Feb 11, 2007
Messages
11
I realise this has probably been covered loads of times but I'm new to this depth of Access and a little baffled!

I have a command button on a form ... this leads me to a print preview. What I need is to click the button in a form view and it will print the current record only.

Could anyone please assist? I know its a printout statement ... but what is the right code?

Many thanks in anticipation :confused:
 
hope this helps

I have done this many time and follow this method.... It assumes that you have a primary (unique) reference to return the single record.

1) create a query on which to base the report that will return a unique record.
e.g select * from table where table.unique_field = 1

2) create your report using this query as the record source.

3) create your button with this code

Dim strSQL as string

strSQL = "SELECT DISTINCTROW table.* " _
& "From Table " _
& "WHERE ((Table.Uniquefield)=" & [UniqueObjectName] & "));"

SetUpQuery "QueryReportIsBasedOn", strSQL
DoCmd.OpenReport "Report", acViewPreview

4) UniqueObjectName is the name of the object on your form that contains the unique reference.
Also if your unique ref is a text string then you need to replace the where bit with this
& "WHERE ((Table.Uniquefield)= '" & [UniqueObjectName] & "'));"

Best of luck
Ant
 
Thanks

Many thanks. I'll try that.
:)
 

Users who are viewing this thread

Back
Top Bottom