S
serviceman via AccessMonster.com
Me again...
I'm having trouble trapping errors in the code below when a duplicate key is
trying to inserted with the DoCmd.RunSQL command (error 2627):
Private Sub Command16_Click()
Dim SQLStr As String
SQLStr = "INSERT TESTRESULTS SELECT '" & Forms!formtestentry.Combo14.Column(0)
& "' as ATT_HDR_ID, STUDENT_ID AS STUDENT_ID,'" & Forms!formtestentry.Combo14.
Column(1) & "' as EVENT_ID, '" & Forms!formtestentry.LOCATION_ID & "' as
LOCATION_ID,'" & Forms!formtestentry.EVENT_DAT & "' as EVENT_DAT, 0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,'','','','','' FROM STUDENTS
WHERE STUDENT_ID IN (" & MySelected2 & ")"
DoCmd.SetWarnings False
DoCmd.RunSQL (SQLStr)
DoCmd.SetWarnings True
Set colCheckBox = Nothing
Me.requery
Forms!formtestentry!subformadminteststudents.requery
End Sub
The code works fine, I'm just trying to beautify the 'violation of primary
key' message. Can someone show me the way?
Thanks a bunch,
Andy
I'm having trouble trapping errors in the code below when a duplicate key is
trying to inserted with the DoCmd.RunSQL command (error 2627):
Private Sub Command16_Click()
Dim SQLStr As String
SQLStr = "INSERT TESTRESULTS SELECT '" & Forms!formtestentry.Combo14.Column(0)
& "' as ATT_HDR_ID, STUDENT_ID AS STUDENT_ID,'" & Forms!formtestentry.Combo14.
Column(1) & "' as EVENT_ID, '" & Forms!formtestentry.LOCATION_ID & "' as
LOCATION_ID,'" & Forms!formtestentry.EVENT_DAT & "' as EVENT_DAT, 0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,'','','','','' FROM STUDENTS
WHERE STUDENT_ID IN (" & MySelected2 & ")"
DoCmd.SetWarnings False
DoCmd.RunSQL (SQLStr)
DoCmd.SetWarnings True
Set colCheckBox = Nothing
Me.requery
Forms!formtestentry!subformadminteststudents.requery
End Sub
The code works fine, I'm just trying to beautify the 'violation of primary
key' message. Can someone show me the way?
Thanks a bunch,
Andy