Printing do not show newly edited data on the active form

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

Guest

I made a print button on a form to print a report for filtered record, but
when i edit data on the active form, the printed report does not update.
To update, i had to click anywhere at a subform, before clicking on the
print button. I think there is a proper way to auto update edited data on
active forms
 
Here is my code to print a report based on the current form. Make sure you
are doing the test for "dirty"...

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
 
Thanks a lot.....

Rick B said:
Here is my code to print a report based on the current form. Make sure you
are doing the test for "dirty"...

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



Ujin Han said:
I made a print button on a form to print a report for filtered record, but
when i edit data on the active form, the printed report does not update.
To update, i had to click anywhere at a subform, before clicking on the
print button. I think there is a proper way to auto update edited data on
active forms
 
Back
Top