right preview but error in printing

  • Thread starter Thread starter almond mendoza via AccessMonster.com
  • Start date Start date
A

almond mendoza via AccessMonster.com

could anyone help me with this???

Option Compare Database
Option Explicit
Public db As DAO.Database
Public rs As DAO.Recordset
Public strSQL As String

Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
If Not rs.EOF Then
If rs.RecordCount > 0 Then
If (txtCounter Mod 2) = 0 Then
recRecord.Visible = True
Else
recRecord.Visible = False
End If

Me.txtappnumber = rs.Fields("AppNumber")
Me.txtsurname = rs.Fields("Surname")
Me.txtFirstname = rs.Fields("Firstname")
Me.Mobile = rs.Fields("Mobile")
Me.txtsex = rs.Fields("Sex")
Me.Remarks = rs.Fields("Remarks")
Me.txtage = (Date - rs.Fields("Birthday")) / 365
Me.Address = rs.Fields("City_Town") & " " & rs.Fields
("Province")
Me.CDegree = rs.Fields("CDegree")
Me.txtcivilstat = rs.Fields("CivilStat")
Me.Landline = rs.Fields("Landline")
rs.MoveNext
Debug.Print
End If
End If
End Sub

Private Sub Report_Close()
Set db = Nothing
Set rs = Nothing
End Sub

Private Sub Report_Open(Cancel As Integer)
Set db = CurrentDb
Set rs = db.OpenRecordset(pstrSQL)
If rs.RecordCount > 0 Then
Report.RecordSource = pstrSQL
Else
MsgBox "No report found"
End If
End Sub

Thank you in advance...
 
the pstrSQL is a variable from other form, and recRecord is just a bar to
be switch on and off, the preview is right with all correct data but when i
print it, it print the last record many times...
 
I'm not sure why you just don't bind your report to the fields from your
query. However, you need code in your Report header section to move to the
first record. I would also expect if you didn't preview the report prior to
printing, it might work.
 
Back
Top