Using a DropDown Lookup to Populate 2 fields in an Access Query or Form

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • SueHopson
    New Member
    • Jan 2020
    • 47

    Using a DropDown Lookup to Populate 2 fields in an Access Query or Form

    Hello Everyone!

    My EmployeeData tbl contains a field PPID_Data (number field). I am using this field to lookup values from another table called PayPeriods, which contains all the data for the year 2021.

    Code:
    SELECT PayPeriods.PPID, PayPeriods.PP, PayPeriods.StartDate, PayPeriods.EndDate
    FROM PayPeriods
    ORDER BY PayPeriods.PP;
    Code:
    PPID	PP	StartDate	EndDate
    1	01 - Week 01	21-Dec-21	27-Dec-20
    2	02 - Week 03	04-Jan-21	10-Jan-21
    I am looking for the best way to have the [StartDate] and [EndDate] update on the form, or using a query, when the user selects the PayPeriod [PP] from the dropdown.

    I was able to successfully get the unbound field [SDate] to populate on the form using the code below, but could never get the [EDate] to work. I'm sure I'm missing something simple, but would be happy to learn if there is a better way to reference the fields.

    Code:
    Private Sub PPID_Data_AfterUpdate()
    Me.SDUnbound = Me.Combo800.Column(2)
    Me.EDUnbound = Me.Combo800.Column(3)
    End Sub
  • MikeTheBike
    Recognized Expert Contributor
    • Jun 2007
    • 640

    #2
    Hi Sue

    Just a thought, is the droplist column count set to 4?

    MTB

    Comment

    • SueHopson
      New Member
      • Jan 2020
      • 47

      #3
      Nope, it hadn't been.
      It's always the little things that get overlooked, isn't it? Thanks Mike!

      Comment

      Working...