Commit Form Data To A Table Before Calling Report
Some user's will enter data in a text box and not tab to the next control. Let's say there is a button on the form that calls a report using the same data that is being updated in the form. The effect of this is that the last field they entered does not get committed before a report is run if the form is still open. The following code demonstrates how to make sure all data from the form is written to the underlying table BEFORE the report is produced. They key statement is the Me.Dirty command.
Program Code
Private Sub cmdPreviewReport_Click() On Error GoTo cmdPreviewReport_Click_Err If Me.Dirty Then Me.Dirty = False DoCmd.OpenReport "Freight Invoice Posting", acViewReport, "", "", acDialog cmdPreviewReport_Click_Exit: Exit Sub cmdPreviewReport_Click_Err: MsgBox Error$ Resume cmdPreviewReport_Click_Exit End Sub