A
am
I have added a Duplicate record button on my form created
using the wizard. When I use it I get a run time error
3022, "duplicate records..........". because ther is some
other code on my form that is saving the record before I
get a chance to change the primary Key field. I know this
is not a clean way to address this but how can I add code
such that if Error=3022 I display a custom message or
ignore it altogether or can somone give me a suggestion on
a better solution. My code(which someone helped me with)
is:
Private Sub MembraneType_AfterUpdate()
Dim strARG As String
Dim strSQL As String
Dim DocName As String
Dim LinkCriteria As String
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, ,
acMenuVer70
If MembraneType = "Other:" Then
strARG = "Membrane Type , SELECT OtherMembraneType as
OtherDescription FROM tblMEA where [MEAnumber] ='" &
MEAnumber & "';"
DocName = "frmOtherDescription"
DoCmd.OpenForm DocName, , , LinkCriteria, , , strARG
Else
strSQL = "UPDATE tblMEA SET OtherMembraneType = null
where [MEAnumber] ='" & MEAnumber & "';"
'MsgBox strSQL
CurrentDb.Execute strSQL
End If
End Sub
using the wizard. When I use it I get a run time error
3022, "duplicate records..........". because ther is some
other code on my form that is saving the record before I
get a chance to change the primary Key field. I know this
is not a clean way to address this but how can I add code
such that if Error=3022 I display a custom message or
ignore it altogether or can somone give me a suggestion on
a better solution. My code(which someone helped me with)
is:
Private Sub MembraneType_AfterUpdate()
Dim strARG As String
Dim strSQL As String
Dim DocName As String
Dim LinkCriteria As String
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, ,
acMenuVer70
If MembraneType = "Other:" Then
strARG = "Membrane Type , SELECT OtherMembraneType as
OtherDescription FROM tblMEA where [MEAnumber] ='" &
MEAnumber & "';"
DocName = "frmOtherDescription"
DoCmd.OpenForm DocName, , , LinkCriteria, , , strARG
Else
strSQL = "UPDATE tblMEA SET OtherMembraneType = null
where [MEAnumber] ='" & MEAnumber & "';"
'MsgBox strSQL
CurrentDb.Execute strSQL
End If
End Sub