Results 1 to 4 of 4
  1. #1
    dimoc is offline Novice
    Windows 7 32bit Access 2013
    Join Date
    Apr 2014
    Posts
    5

    warning message if field is left blank

    I have a questions database. When user is filling out the form, the following fields are required: Questions, Author, Type of Question and Answer selected. Answer is selected by clicking on the button next to the Answers. If these fields are not filled out, a user gets a prompt saying that so and so field is blank. If have a problem, it works for all required fields except for Answer. Below is my code. I have attached a screenshot with Author and Answers blank. I only get a warning about the Author and not the Answers.



    Code:
    Private Sub Form_BeforeUpdate(Cancel As Integer)
        
        nullerr = 0
        strnull = ""
    
    
        If IsNull(Me.txtQuestion) Then
            nullerr = 1
            strnull = "Questions " & vbNewLine
        End If
    
    
        If IsNull(Me.txtAuthor) Then
            nullerr = 1
            strnull = strnull & "Author " & vbNewLine
        End If
    
    
        If IsNull(Me.comboType) Then
            nullerr = 1
            strnull = strnull & "Type " & vbNewLine
        End If
    
    
        If IsNull(Me.toggleA) Or IsNull(Me.toggleB) Or IsNull(Me.toggleC) Or IsNull(Me.toggleD) Then
            nullerr = 1
            strnull = strnull & "Answer"
        End If
    
    
        If nullerr Then
            MsgBox "These fields cannot be left blank: " & vbNewLine & strnull
            DoCmd.RunCommand acCmdUndo
        End If
    Attached Thumbnails Attached Thumbnails help2.jpg  

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    If you're testing the toggle buttons, I'm pretty sure they are always True or False, never Null. You probably want to test the textboxes next to them.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    dimoc is offline Novice
    Windows 7 32bit Access 2013
    Join Date
    Apr 2014
    Posts
    5
    You're absolutely right. The following code worked for me. optgroupAnswers being the Option Group for the four toggle buttons.

    If (Me.optgroupAnswers = 0) Then

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Ah, didn't realize it was an option group. You are correctly testing the frame value if that's the case.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

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

Similar Threads

  1. Pop Message Box Warning
    By data808 in forum Programming
    Replies: 4
    Last Post: 01-11-2014, 04:43 PM
  2. Access Warning Message
    By marksnwv in forum Access
    Replies: 1
    Last Post: 06-01-2012, 01:46 PM
  3. remove Macro Warning message
    By Jerseynjphillypa in forum Programming
    Replies: 3
    Last Post: 05-09-2012, 10:22 AM
  4. Warning Message for Missed Date
    By maintt in forum Access
    Replies: 2
    Last Post: 07-23-2010, 09:05 AM
  5. Access warning message
    By John Southern in forum Access
    Replies: 2
    Last Post: 05-28-2010, 06:01 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