Results 1 to 6 of 6
  1. #1
    PaulJMC is offline Novice
    Windows 10 Access 2010 64bit
    Join Date
    Apr 2020
    Posts
    3

    Making a field mandatory on a field using VBA


    I am creating a form to track customer contact in.
    I want to ma a field mandatory using VBA but don't know where to start.

    The

  2. #2
    PaulJMC is offline Novice
    Windows 10 Access 2010 64bit
    Join Date
    Apr 2020
    Posts
    3
    I submitted before I typed everything. I want to make the field "outcome" mandatory and want it so the form cannot be saved without this being completed first.

    My current VBA Is


    Private Sub Command165_Click()



    DoCmd.GoToRecord , , acNewRec



    Customer_ID.Value = ""
    Chat_Type = ""
    Staff_Name = ""
    Reason_for_Chat = ""
    Reason_2 = ""
    Reason_3 = ""
    Free_Text = ""
    Feedback = ""
    Outcome = ""


    txtDates.Value = Format(Date, "dd/mm/yyyy")
    txtDates.Locked = True
    txtTimes.Value = Format(Time, "HH:MM:SS")
    txtTimes.Locked = True



    End Sub

  3. #3
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    This may help, but I'd also make the field required in the table.

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

  4. #4
    PaulJMC is offline Novice
    Windows 10 Access 2010 64bit
    Join Date
    Apr 2020
    Posts
    3
    Quote Originally Posted by pbaldy View Post
    This may help, but I'd also make the field required in the table.

    http://www.baldyweb.com/BeforeUpdate.htm
    Thanks for the support. I tried this in a few different places and either it didn't validate or it came up with an error.

  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,518
    Like I said, I'd make the field required in the table. As you your error, I can't say without seeing your exact code and where you put it.
    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,016
    Quote Originally Posted by PaulJMC View Post
    ...I tried this in a few different places and either it didn't validate or it came up with an error...
    It has to be in the Form_BeforeUpdate event.

    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. Replies: 2
    Last Post: 06-17-2019, 10:28 AM
  2. Validation Rule / Mandatory Field
    By Banker_Sam in forum Forms
    Replies: 9
    Last Post: 12-05-2017, 10:17 AM
  3. Replies: 1
    Last Post: 12-04-2016, 05:43 PM
  4. Replies: 5
    Last Post: 07-24-2014, 09:32 AM
  5. Replies: 1
    Last Post: 11-04-2011, 06:53 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