Results 1 to 12 of 12
  1. #1
    jinz is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Nov 2012
    Posts
    13

    Incomplete form


    I have a customer form with the typical data

    E.g customer first name customer last name address, etc

    However how do in access have a pop up message if the user doesn't complete the form like say for example they do not fill in the 'customer last name' field?thanks

  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
    One way is to make the field required in the table. Another:

    http://www.baldyweb.com/BeforeUpdate.htm
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,018
    There are multiple ways to do this, as Paul indicated, but I generally use the following:

    Set the Tag Property, for all Controls that you want to have checked, to Required (no Quotes, please.)

    To set the Tag Property for multiple Controls, in one fell swoop:

    1. Go into Form Design View
    2. Holding down <Shift> and Left clicking on each Control in turn, to select it.
    3. Go to Properties – Other and enter your value (Required) in the Tag Property; it's the last Property under Other.

    Now, add this code behind your Form:

    Code:
    Private Sub Form_BeforeUpdate(Cancel As Integer)
    Dim ctl As Control
    
    For Each ctl In Me.Controls
        
           If ctl.Tag = "Required" Then
             If Nz(ctl,"") ="" Then
               Cancel = True
               Msgbox ctl.Name & "  is a Required Field and Must Have Data Entered"
               ctl.SetFocus
               Exit Sub
             End If
         End If
     Next
    
    End Sub


    You should now be set!

    Linq ;0)>
    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

  4. #4
    jinz is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Nov 2012
    Posts
    13
    wow, thanks very much guys, on other quick question please

    I have a field called customergender, a user can only type "M" or "F", however it still works if I type a random letter in such as "v"

    Do you know the "event on change" so when the select the field and change/type in a random letter I want to have a pop up message saying something like "You can only type "M" for male or "F" for female?

    thanks very much.

  5. #5
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    I might use a combo box with those two selections and its limit to list property set to yes. You can also use code in the before update event of the control or form:

    http://www.baldyweb.com/BeforeUpdate.htm
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  6. #6
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,018
    Code:
    Private Sub customergender_BeforeUpdate(Cancel As Integer)
     If Me.customergender <> "M" And Me.customergender <> "F" Then
      MsgBox "You can only type M for male or F for female!"
      Cancel = True
      Me.customergender.SelStart = 0
      Me.customergender.SelLength = Len(Me.customergender)
     End If
    End Sub

    This expansion of the example Paul gave will do it, but using a Control to limit the user to M or F, as he suggested, would really be preferable, to my way of thinking. In addition to a Combobox, you could also use an Option Group with two Option (aka Radio) Buttons.

    Linq ;0)>
    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

  7. #7
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,018
    Please don't send Private Messages to members as part of a continuing thread, post back here, instead!

    I have no idea what

    "still works ^ I don't want that"

    means! The code I gave you should prevent the user from successfully entering anything other than M or F, popping up a MessageBox, as you requested, and then selecting the erroneous entry, allowing them to press M or F, as instructed. If that doesn't work for you, you need to explain your problem better.

    Linq ;0)>
    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

  8. #8
    jinz is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Nov 2012
    Posts
    13
    solved thanks all!
    Last edited by jinz; 12-12-2012 at 07:25 AM.

  9. #9
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    The first declares a variable to be used to represent a control. The second tests the current control in the loop to see if is either Null or contains a zero length string (""). The third sets focus to that control if it has either.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  10. #10
    jinz is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Nov 2012
    Posts
    13
    solved please delete this thread thanks.
    Last edited by jinz; 12-12-2012 at 07:23 AM.

  11. #11
    jinz is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Nov 2012
    Posts
    13
    thanks guys a mod/admin can delete this thread now thanks

  12. #12
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,018
    We don't 'delete' resolved threads! Your simple acknowledgment that a response has resulted in a resolution of your problem is adequate! Resolved threads are important in that they provide a resource for people searching for answers to identical or similar problems!

    Glad we could help!

    Linq ;0)>
    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

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

Similar Threads

  1. Incomplete Syntax Clause (syntax error)
    By ajetrumpet in forum Programming
    Replies: 4
    Last Post: 09-11-2010, 10:47 AM
  2. Generating reports by incomplete field
    By mathonix in forum Reports
    Replies: 2
    Last Post: 01-28-2010, 06:37 PM

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