J
John Pritchard
I'm testing various ideas to make Access forms work elegently - eliminate
meaningless default messages etc. One idea is to set values in the table defn
- required = yes etc - then trap data errors in the forms Form Error section.
Questions:-
1. Where can I findout what the DataErr numbers mean
2. What does response do
Here's my test code so for - I've been guessing but it seems to work
reasonable except when I delete the PrimKey (indexed no dups in the table
def) on an existing record when I can't move from the field for some reason.
Private Sub Form_Error(DataErr As Integer, Response As Integer)
Select Case DataErr
Case 3022
MsgBox "Primkey already exists"
DoCmd.GoToControl "Primkey"
Case 3314
If IsNull(Me.PrimKey) Then
MsgBox "PrimKey can not be null"
DoCmd.GoToControl "Primkey"
ElseIf IsNull(Me.Fldone) Then
MsgBox "Fldone can not be null"
DoCmd.GoToControl "Fldone"
End If
Case 2169
MsgBox "Changes to this record can not be saved"
Case Else
MsgBox "DataErr was " & DataErr
End Select
Response = vbCancel
End Sub
Thanks for any help / guidance - I think I've lots to still learn but need
pointing in the right direction!
meaningless default messages etc. One idea is to set values in the table defn
- required = yes etc - then trap data errors in the forms Form Error section.
Questions:-
1. Where can I findout what the DataErr numbers mean
2. What does response do
Here's my test code so for - I've been guessing but it seems to work
reasonable except when I delete the PrimKey (indexed no dups in the table
def) on an existing record when I can't move from the field for some reason.
Private Sub Form_Error(DataErr As Integer, Response As Integer)
Select Case DataErr
Case 3022
MsgBox "Primkey already exists"
DoCmd.GoToControl "Primkey"
Case 3314
If IsNull(Me.PrimKey) Then
MsgBox "PrimKey can not be null"
DoCmd.GoToControl "Primkey"
ElseIf IsNull(Me.Fldone) Then
MsgBox "Fldone can not be null"
DoCmd.GoToControl "Fldone"
End If
Case 2169
MsgBox "Changes to this record can not be saved"
Case Else
MsgBox "DataErr was " & DataErr
End Select
Response = vbCancel
End Sub
Thanks for any help / guidance - I think I've lots to still learn but need
pointing in the right direction!