I have a bound form (NCREdit) on which my users enter information and updates regarding rejections. On this form, there are four subforms and multiple buttons.
Two of the buttons open a report based on the record shown on the form; one opens the report in preview mode, the other prints it straight to the user's default printer.
We have encountered issues where once the data on the main form has been entered, changes to that data are not always applied when the user opens the report. It appears that changes to subform data work correctly. I attempted to fix this issue through the On Click event by adding code to 1) reset the form focus to the date field and 2) refresh the form data before opening the report. Here is the On Click event code currently in use:
[tt]
Private Sub cmdOpenReport_Click()
On Error GoTo Err_cmdOpenReport_Click
Me.NCRDate.SetFocus
DoCmd.DoMenuItem acFormBar, acRecordsMenu, 5, , acMenuVer70
Dim stDocName As String
stDocName = "NCRreport"
DoCmd.OpenReport stDocName, acPreview, , "NCRno = '" & Me.NCRno & "'"
Exit_cmdOpenReport_Click:
Exit Sub
Err_cmdOpenReport_Click:
MsgBox Err.Description
Resume Exit_cmdOpenReport_Click
End Sub
[/tt]
Although adding these lines to the code appears to have reduced the number of times the issue comes up, it has not stopped it. Can anyone suggest a better way or an additional safeguard?
Cheryl dc Kern
Two of the buttons open a report based on the record shown on the form; one opens the report in preview mode, the other prints it straight to the user's default printer.
We have encountered issues where once the data on the main form has been entered, changes to that data are not always applied when the user opens the report. It appears that changes to subform data work correctly. I attempted to fix this issue through the On Click event by adding code to 1) reset the form focus to the date field and 2) refresh the form data before opening the report. Here is the On Click event code currently in use:
[tt]
Private Sub cmdOpenReport_Click()
On Error GoTo Err_cmdOpenReport_Click
Me.NCRDate.SetFocus
DoCmd.DoMenuItem acFormBar, acRecordsMenu, 5, , acMenuVer70
Dim stDocName As String
stDocName = "NCRreport"
DoCmd.OpenReport stDocName, acPreview, , "NCRno = '" & Me.NCRno & "'"
Exit_cmdOpenReport_Click:
Exit Sub
Err_cmdOpenReport_Click:
MsgBox Err.Description
Resume Exit_cmdOpenReport_Click
End Sub
[/tt]
Although adding these lines to the code appears to have reduced the number of times the issue comes up, it has not stopped it. Can anyone suggest a better way or an additional safeguard?
Cheryl dc Kern