Consulting

Results 1 to 4 of 4

Thread: As form before update evet not triggering

  1. #1
    VBAX Regular
    Joined
    Oct 2017
    Posts
    14
    Location

    As form before update evet not triggering

    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
    Last edited by SamT; 12-07-2017 at 04:13 PM. Reason: Added Code Formatting Tags via # Icon

  2. #2
    Moderator VBAX Sage SamT's Avatar
    Joined
    Oct 2006
    Location
    Near Columbia
    Posts
    7,814
    Location
    : '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
    I expect the student to do their homework and find all the errrors I leeve in.


    Please take the time to read the Forum FAQ

  3. #3
    VBAX Regular
    Joined
    Oct 2017
    Posts
    14
    Location
    thanks SamT but i have resolved this issue a while back thanks for the reply appreciate it.

  4. #4
    Moderator VBAX Sage SamT's Avatar
    Joined
    Oct 2006
    Location
    Near Columbia
    Posts
    7,814
    Location
    What was the solution? (Help our other guests out)
    I expect the student to do their homework and find all the errrors I leeve in.


    Please take the time to read the Forum FAQ

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •