Results 1 to 2 of 2
  1. #1
    jlgray0127 is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2011
    Location
    Central Illinois
    Posts
    193

    Required Input with VBA

    Hello all!
    Can someone help me with this code? (below)
    In the first field in my form, the user is required to enter the name of the project. I do not want the user to be able to leave this field, without entering this information.
    I'm not sure what is wrong with the code below, but it is not working.

    Private Sub Program_Name_BeforeUpdate(Cancel As Integer)
    If Len(Trim(Me.Program_Name)) & vbNullString = 0 Then
    MsgBox "You must enter the Program Name.", vbInformation & vbOKOnly, "Entry Required"
    Cancel = True
    End If
    End Sub

    Can you please help?
    Thank you!

  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,652
    The problem with the before update event is it only fires if the user changes something ("updates" the data). I personally would use the before update event of the form. Alternatively you might disable other controls until the user enters something in this one.
    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. Replies: 5
    Last Post: 01-29-2014, 02:42 PM
  2. Input Forms - How To Input Multiple Fields/Records?
    By butterbescotch in forum Forms
    Replies: 1
    Last Post: 04-04-2013, 06:30 AM
  3. Replies: 3
    Last Post: 01-15-2012, 02:46 PM
  4. immediate help required
    By pdurgi in forum Access
    Replies: 1
    Last Post: 06-05-2009, 08:21 PM
  5. Set required user input
    By ZeusOsiris in forum Database Design
    Replies: 2
    Last Post: 12-04-2006, 07:13 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