Results 1 to 4 of 4
  1. #1
    srmezick is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Oct 2011
    Posts
    15

    Requiring a feild based on another feild's drop down menu

    I have a table (Employee Information) which contains (among others) the feilds Status, Termination Date, and Termination Reason. I know nothing about writing code so if someone wouldnt mind jotting me a code that would make the feilds Termination Date and Termination Reason required when the Status is changed to "Terminated" in the drop down box. (Ill also need to know whether to put it in the update before or after or whichever place it will need to go. Thanks!



    If necessary I have the same fields in a form "Employee Snapshot", which is where the information will be recorded, and ideally this function would run from that form.

    So if the feild Status = Terminated from drop down box, need feild "Termination Date" and feild "Termination Reason" to be required in the form Employee Snapshot.

    Trying to be as specific as possible.

  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,530
    It would go in the before update event of the form:

    http://www.baldyweb.com/BeforeUpdate.htm

    Post back if you have trouble with your specific test.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    srmezick is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Oct 2011
    Posts
    15
    If Len(Me.SomeControl & vbNullString) = 0 Then
    MsgBox "You need to fill out SomeControl"
    Cancel = True
    Me.SomeControl.SetFocus
    End If

    would become:

    If Len(Me.TerminationDate & vbNullString) = 0 Then
    MsgBox "You need to fill out Termination Date!"
    Cancel=True
    me.TerminationDate.SetFocus
    End If

    ??

    Can I make it dependent on if the expression in Status = "Termination"?

    As they wont need a termination date or reason for employees that are not terminated.

  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,530
    Your test becomes:

    If Me.Status = "Termination" And Len(Me.TerminationDate & vbNullString) = 0 Then

    For a date, you can also test with IsDate, so something like:

    If Me.Status = "Termination" And Not IsDate(Me.TerminationDate) Then
    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. Saving unbound feild values
    By John Saul in forum Access
    Replies: 1
    Last Post: 06-19-2013, 06:22 AM
  2. Replies: 3
    Last Post: 11-24-2011, 10:07 AM
  3. Cut/Paste Feild values to new record
    By nickiwinki in forum Access
    Replies: 14
    Last Post: 10-25-2011, 11:56 AM
  4. To feild in send object from Form
    By forrestapi in forum Forms
    Replies: 16
    Last Post: 07-29-2010, 03:05 PM
  5. Replies: 2
    Last Post: 03-14-2010, 07:27 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