Results 1 to 2 of 2
  1. #1
    newbieX is offline Competent Performer
    Windows 7 64bit Access 2007
    Join Date
    Jul 2013
    Posts
    111

    BeforeEvent triggers only once in datasheet view on form

    I have a subform displaying in datasheet view. I am checking to see if all the required data is enter before going to another record and if not, a pop up a message appears and the cursor goes to the required field that is not filled out. The problem is that it works on the first go around, but not subsequent go arounds for the same record.

    For instance, if the user forgets to enter the name of the client and goes to a new record, the pop up message will appear and go to the "txtName" data entry field of the record they were just entering. However, if the user still does NOT fill out the name (after the initial message) and goes to the next record, no pop up message occurs. Why isn't the BeforeUpdate event triggered the second time around? Is there a different event I should be putting this code?


    Code:
    Private Sub Form_BeforeUpdate(Cancel As Integer)
    
    Dim ctr As Control
    Dim var As String
    
    For Each ctl In Me.Controls
        If ctl.Tag = "required" Then
            Debug.Print "Required"
            var = ctl.ControlTipText
            If ctl = "" Or IsNull(ctl) Then
                MsgBox "You've have not checked all the required steps for this record. Please see the following " + var, 48, "More Info Required!"
                ctl.SetFocus
                Exit Sub
            End If
        End If
    Next
    End Sub
    Access 2007

  2. #2
    newbieX is offline Competent Performer
    Windows 7 64bit Access 2007
    Join Date
    Jul 2013
    Posts
    111
    Figured it out all on my own after all (proud pat on the back)

    I needed to put "Cancel = True" after the message box.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 3
    Last Post: 08-18-2013, 09:14 PM
  2. Replies: 6
    Last Post: 11-21-2012, 05:10 PM
  3. Replies: 16
    Last Post: 09-12-2012, 08:39 AM
  4. Datasheet view sub form
    By Irishlad1967 in forum Forms
    Replies: 2
    Last Post: 05-10-2012, 09:23 PM
  5. Form - Datasheet View
    By kalove in forum Forms
    Replies: 0
    Last Post: 06-20-2007, 11:29 AM

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
  •  
Other Forums: Microsoft Office Forums