PDA

View Full Version : [SOLVED:] As form before update evet not triggering



Rickz
12-07-2017, 02:23 PM
hi i have stuck in the forms update event where the event is not firing up.
i have to check or validate certain feilds and have to make sure they are not empty in the fields. example i have 8 fields.


Private Sub Form_BeforeUpdate(Cancel As Integer)

If IsNull(Form_Master.Primary_Key) = True Then

Me!Primary_Key.SetFocus
Msg = "Please enter Primary key"
Style = vbCritical
Title = "Data Record Entry"
Response = MsgBox(Msg, Style, Title)
If Response = vbOKOnly Then ' User choose Yes.
MyString = "Yes" ' Perform some action.
End If
Cancel = True
Exit Sub
ElseIf IsNull(Form_Master.AddSuffix) = True Then

Me!AddSuffix.SetFocus
Msg = "Please enter AddSuffix"
Style = vbInformation
Title = "Data Record Entry"
Response = MsgBox(Msg, Style, Title)
If Response = vbOKOnly Then ' User choose Yes.
MyString = "Yes" ' Perform some action.
End If
Cancel = True
Exit Sub
ElseIf CppValue.ListIndex = -1 Then

Me!CppValue.SetFocus
Msg = "Please enter Grouping information"
Style = vbInformation
Title = "Data Record Entry"
Response = MsgBox(Msg, Style, Title)
If Response = vbOKOnly Then ' User choose Yes.
MyString = "Yes" ' Perform some action.
End If
Cancel = True
Exit Sub

SamT
12-07-2017, 04:17 PM
:dunno: 'bout Access, but in VBA for Excel

Me!Primary_Key.SetFocus
Should be

Me.Primary_Key.SetFocus

Cancel is an Integer. Try using

Cancel = -1

Rickz
12-07-2017, 04:53 PM
thanks SamT but i have resolved this issue a while back thanks for the reply appreciate it.

SamT
12-07-2017, 07:44 PM
What was the solution? (Help our other guests out)