I have a code that opens a MsgBox if the CASE NO already been entered, now I need the code for the "Yes I want to see this already entered record"
I am working in Access 97 (no Wizzards are working)
CASE NO is primary key in the CRASH DATA TABLE
CASE NO if first field on CRASH DATA FORM
This code works at identifing the duplicate record and brings up the MsgBox but the Yes / No buttons only remove the message box window and bring me back to the record with the duplicate case number just entered (the one that brought up the massage box)
Private Sub CASE_NO_BeforeUpdate(Cancel As Integer)
If Not IsNull(DLookup("[CASE NO]","[CRASH DATA TABLE]",_
"[CASE NO]='" & Forms![CRASH DATA FORM]![CASE NO] & "'")) Then
Cancel = True
If Me.NewRecord Then
MsgBox "THIS RECORD IS ALREADY ENTERED." & vbNewLine &_
"WOULD YOU LIKE TO VIEW THIS RECORD?", _
vbExclamation + vbYesNo
Else
Me![CASE NO].Undo
End If
End If
End Sub
I know I have to put a criteria for where to send the vbYes and I have tried several different things
like If vbYes Then GoTo[CRASH DATA FORM]Me![CASE NO]
If vbYes Then GoTo[CASE NO]
If vbYes Then DoCmd.GoToRecord asGoTo,[CASE NO]
and many more, I am lost and fustrated and I am also a code novice, everything I have so far is trial and error (lots of error!)
SOMEONE PLEASE HELP! Tell me what to put in the "CRITERIA"
I am working in Access 97 (no Wizzards are working)
CASE NO is primary key in the CRASH DATA TABLE
CASE NO if first field on CRASH DATA FORM
This code works at identifing the duplicate record and brings up the MsgBox but the Yes / No buttons only remove the message box window and bring me back to the record with the duplicate case number just entered (the one that brought up the massage box)
Private Sub CASE_NO_BeforeUpdate(Cancel As Integer)
If Not IsNull(DLookup("[CASE NO]","[CRASH DATA TABLE]",_
"[CASE NO]='" & Forms![CRASH DATA FORM]![CASE NO] & "'")) Then
Cancel = True
If Me.NewRecord Then
MsgBox "THIS RECORD IS ALREADY ENTERED." & vbNewLine &_
"WOULD YOU LIKE TO VIEW THIS RECORD?", _
vbExclamation + vbYesNo
Else
Me![CASE NO].Undo
End If
End If
End Sub
I know I have to put a criteria for where to send the vbYes and I have tried several different things
like If vbYes Then GoTo[CRASH DATA FORM]Me![CASE NO]
If vbYes Then GoTo[CASE NO]
If vbYes Then DoCmd.GoToRecord asGoTo,[CASE NO]
and many more, I am lost and fustrated and I am also a code novice, everything I have so far is trial and error (lots of error!)
SOMEONE PLEASE HELP! Tell me what to put in the "CRITERIA"