He has a routine (see code below) that enables the user to update a form whose recordsource is a query which is a join between two tables. See attachment. After the recordsource is updated, the goal is to print a report using the updated data (see code).
If the form is updated and then closed and then reopened by the user, all is well. The report is able to be printed. However, if the user clicks the command75 button after he/she updates the form, an error 3022 is produced on the
DoCmd.RunCommand acCmdSaveRecord statement.
Is there an alternative to using this statement to update the record source? We are not even sure which of the two tables is producing the duplicate error.
Code: Select all
Private Sub Command75_Click()
Dim strwhere As String
On Error GoTo Err_Command75_Click
DoCmd.RunCommand acCmdSaveRecord
frm256ErrorMsg = ""
strwhere = "[tbl330id] = " & Me.[badge number]
If IsNull(Badge_Number) Then
frm256ErrorMsg = "Please search for a member before pressing ""Print A Badge"" button"
Exit Sub
End If
DoCmd.OpenReport "rptBadgeVolunteer", acViewPreview, , strwhere
GoTo Exit_Command75_Click
Screen.PreviousControl.SetFocus
DoCmd.FindNext
Exit_Command75_Click:
Exit Sub
Err_Command75_Click:
MsgBox Err.Description
Resume Exit_Command75_Click
End Sub