Hello Guru's of Access again i need your expert guidance
I am just trying to learn (during my free time)
My training table consist of 3 fields and using unbound form
1st field custid (text field)
This can't be NIL or Can't duplicate
What I am looking for learning point of view (duel check at same field with different behaviour)
If record is duplicate "Popup message" and curser move back to same field
If field is empty "popup message" Do you want to continue, If yes, move back to field if NO, close form
Therefore, on Before Update event I wrote the following (which was previous help-out by one of Access Guru (thank you again)
Private sub txtcid_beforeupdate (cancel as Integer)
If Dcount("[custid]", "[customerdetails]", "[custid]='" & me.txtcid & "'") > 0 Then
MsgBox "Customer ID already Exists !!!!"
Cancel = True
Me.Txtcid.Undo
End if
(above statement works perfectly (thanks to Access Guru)
------------
If me.txtcid = "" then
If MsgBox ("Message", vbQuestion + vbYesNo, "Test") = vbYes Then
Cancel = True
Me.txtcid.undo
else
docmd.close
end if
end if
end sub
Just a quick update "I tried to used YES or NO option in Exit event too, but no success
eagerly waiting for expert and learning guidance
I am just trying to learn (during my free time)
My training table consist of 3 fields and using unbound form
1st field custid (text field)
This can't be NIL or Can't duplicate
What I am looking for learning point of view (duel check at same field with different behaviour)
If record is duplicate "Popup message" and curser move back to same field
If field is empty "popup message" Do you want to continue, If yes, move back to field if NO, close form
Therefore, on Before Update event I wrote the following (which was previous help-out by one of Access Guru (thank you again)
Private sub txtcid_beforeupdate (cancel as Integer)
If Dcount("[custid]", "[customerdetails]", "[custid]='" & me.txtcid & "'") > 0 Then
MsgBox "Customer ID already Exists !!!!"
Cancel = True
Me.Txtcid.Undo
End if
(above statement works perfectly (thanks to Access Guru)
------------
If me.txtcid = "" then
If MsgBox ("Message", vbQuestion + vbYesNo, "Test") = vbYes Then
Cancel = True
Me.txtcid.undo
else
docmd.close
end if
end if
end sub
Just a quick update "I tried to used YES or NO option in Exit event too, but no success
eagerly waiting for expert and learning guidance