Printing a report to reflect the current record.

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Have a data entry form with several command buttons being used. One is PRINT
CURRENT RECORD, which is supposed to print the record on the screen, but when
I click it, it prints off ALL of the records. How can I have it just print
the current viewable record ?

Any help is appreciated,

Thank You.
 
Check out my coding and tell me if this is correct please ?????
Daily_ticket# is the primary key and is Auto Generated when the form is open.

Private Sub PreviewCurrentRecord_Click()
On Error GoTo Err_PreviewCurrentRecord_Click

Dim stDocName As String

stDocName = "Daily"
DoCmd.OpenReport stDocName, acPreview
strWhere = "[Daily_ticket#] = " & Me.[Daily_Ticket#]

Exit_PreviewCurrentRecord_Click:
Exit Sub

Err_PreviewCurrentRecord_Click:
MsgBox Err.Description
Resume Exit_PreviewCurrentRecord_Click

End Sub
 
Pardon me for sticking my head in here. I imagine that Allen Browne may be
offline at this time, so I'll butt in.

Private Sub PreviewCurrentRecord_Click()
On Error GoTo Err_PreviewCurrentRecord_Click

Dim stDocName As String
Dim strWhere as String '<-- Dim your variable

stDocName = "Daily"

'Populate your variable
strWhere = "[Daily_ticket#] = " & Me.[Daily_Ticket#]

'Use your variable
DoCmd.OpenReport stDocName, acPreview,,strWhere


Exit_PreviewCurrentRecord_Click:
Exit Sub

Err_PreviewCurrentRecord_Click:
MsgBox Err.Description
Resume Exit_PreviewCurrentRecord_Click

End Sub
Check out my coding and tell me if this is correct please ?????
Daily_ticket# is the primary key and is Auto Generated when the form is open.

Private Sub PreviewCurrentRecord_Click()
On Error GoTo Err_PreviewCurrentRecord_Click

Dim stDocName As String

stDocName = "Daily"
DoCmd.OpenReport stDocName, acPreview
strWhere = "[Daily_ticket#] = " & Me.[Daily_Ticket#]

Exit_PreviewCurrentRecord_Click:
Exit Sub

Err_PreviewCurrentRecord_Click:
MsgBox Err.Description
Resume Exit_PreviewCurrentRecord_Click

End Sub

Allen Browne said:
See:
Print the record in the form
at:
http://allenbrowne.com/casu-15.html

The article explains how to use the primary key value of the record in the
WhereCondition of OpenReport.
 
Back
Top