Results 1 to 4 of 4
  1. #1
    MichaelSB is offline Novice
    Windows 10 Access 2016
    Join Date
    Aug 2020
    Posts
    12

    compare table field to form entry

    Hello,



    I am new to access and was wondering about comparing data from a specific table with the entry of a form. For example, First I have a table called Overtime and in that table I have a two fields Staff_Number and Overtime_Date. I use the Staff_Number to associate the Overtime_Date to an employee. Second, I have a form that has a combo box(Input_Staff is the name), text box(Input_Date is the name) and a button(Add_Overtime is the name). If I select the Staff_Number from the combo box(Input_Staff) then input the date of say 8/26/2020 in the textbox(Input_Date) how do I then call the data from the table(Overtime) to compare these values?

    For instance the button I have I want to be able to code it so when clicked I can have an if statement like:

    Code:
    If ((Input_Date) > (Overtime.Overtime_Date)) Then
        Do This
    Else
        Do this
    END If
    At the same time I would need the statement to also be able to figure out which date to pull for instance if input_date is > overtime.overtime_date where input_staff = staff_number.

    I appreciate any assistance given. 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,521
    Sounds like a DLookup() would work:

    http://www.theaccessweb.com/general/gen0018.htm
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    MichaelSB is offline Novice
    Windows 10 Access 2016
    Join Date
    Aug 2020
    Posts
    12
    Perfect worked like a charm.

  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,521
    Excellent! Welcome to the site by the way.
    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: 3
    Last Post: 04-18-2017, 02:40 AM
  2. Replies: 3
    Last Post: 06-04-2015, 09:48 AM
  3. Replies: 5
    Last Post: 05-02-2012, 07:56 AM
  4. Replies: 4
    Last Post: 04-18-2011, 07:18 AM
  5. Replies: 3
    Last Post: 05-19-2010, 10:08 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