Results 1 to 3 of 3
  1. #1
    malamute20 is offline Novice
    Windows XP Access 2010 32bit
    Join Date
    Aug 2011
    Posts
    22

    Require data entry before updating record and emailing form

    Hello.



    I have a Form which is used by a security team to create reports on incidents encountered on their shift and email out to department heads.

    I have a command box which is coded to send the report as email when pressed, and save and close the record.

    I have code to ensure data goes into all the fields.

    My problem is, as I am using a command box for the Submit button, and there is no "Before Update" event on the command box, I'm not sure how to make it check all the fields for data BEFORE allowing the email dialogue to pop up.

    Existing Code follows:

    Code:
    Private Sub Submit_GotFocus()
    Dim cCont As Control
        For Each cCont In Me.Controls
            If TypeName(cCont) = "TextBox" Then
                If IsNull(cCont) Then
                    MsgBox "Please provide a description for " & cCont.Name & " field(s)!"
                    Exit Sub
                    End If
                End If
            Next cCont
     
        For Each cCont In Me.Controls
            If TypeName(cCont) = "ComboBox" Then
                If IsNull(cCont) Then
                    MsgBox "Please provide a description for " & cCont.Name & " field(s)!"
                    Exit Sub
                    End If
                End If
            Next cCont
    End Sub
    I'm using GotFocus which obviously won't handle it the way I want to, but that's easy enough to change once I know how to do what I want to do. Help please =)
    Last edited by malamute20; 08-02-2011 at 07:26 AM.

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,818
    Don't see why this wouldn't work in the command button click event. The Exit Sub lines will cause execution to bypass send email code.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    malamute20 is offline Novice
    Windows XP Access 2010 32bit
    Join Date
    Aug 2011
    Posts
    22
    Quote Originally Posted by June7 View Post
    Don't see why this wouldn't work in the command button click event. The Exit Sub lines will cause execution to bypass send email code.

    Aye, I must be brain dead - didn't even think of structuring the code that way. It works, this is solved, thank you.

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

Similar Threads

  1. Replies: 4
    Last Post: 05-30-2011, 08:20 PM
  2. Replies: 6
    Last Post: 05-05-2011, 08:50 AM
  3. Updating record based on textbox entry
    By timmy in forum Programming
    Replies: 16
    Last Post: 04-06-2011, 12:05 AM
  4. SetFocus/Require Entry
    By mbake085 in forum Programming
    Replies: 5
    Last Post: 08-19-2010, 07:32 AM
  5. blank on entry on add a record form
    By gmee in forum Forms
    Replies: 1
    Last Post: 10-07-2009, 07:31 AM

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