Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

from form, need code to print current record from report 1

Status
Not open for further replies.

DennisAtWork

IS-IT--Management
Jan 8, 2002
17
CA
Hello, I'm using Access 2000. From a form I have, I need to print the current record from a Report.

Does anyone know how?

..much thanks,
 
Dennis
Assuming that your record has a [RecordID], to identify the record you wish to print, put a command button on your form to open the report you wish to print. Then include code behind the command button to print the specific record.

For example...
DoCmd.OpenReport YourReportName, acPreview, "", "[RecordID]=[Forms]![YourFormName]![RecordID]"

You may also wish to include code to Save the current record, as that will be needed in cases where you are printing a record you have just concluded entering.

You will, of course, have to modify this so that it has your report and form names, etc.

Tom
 
Tom Watson was right on the money.
THANKS TOM!!!!!!!!

below is the final code I used in case anyone else is wondering about this:

Private Sub Print_Doulbe_Copy_Click()
On Error GoTo Err_Print_Doulbe_Copy_Click

Dim stDocName As String
Dim stWhere As String
stWhere = "[RecordID]=[Forms]![Reservation Yacht Form]![RecordID]"
stDocName = "Visitors-2CopiesOnPage"
DoCmd.OpenReport stDocName, acPreview, "", stWhere
' change acPreview to acNormal to print immediately instead of with preview

Exit_Print_Doulbe_Copy_Click:
Exit Sub

Err_Print_Doulbe_Copy_Click:
MsgBox Err.Description
Resume Exit_Print_Doulbe_Copy_Click
End Sub


thanks again Tom!

sincerely
Dennis.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top