Results 1 to 6 of 6
  1. #1
    Tomfernandez1 is offline Advanced Beginner
    Windows XP Access 2003
    Join Date
    Feb 2011
    Posts
    74

    Data Lookup via Drop Down Fields

    Hello,

    I have a Table that has the following fields:

    RTM
    4day
    5day
    7day



    RTM = round trip miles: 20;25;30;35.....
    4day shows rates based on the RTM for a 4day work week
    5day shows rates based on the RTM for a 5day work week
    and so on...

    I would like to create two drop down fields and a text box on a Form. The first drop down shows RTM (20-200 in five-mile increments). The second drop down shows work week options. Based on the options selected in the two drop down fields, I would like to text box to show the resulting fare, say for example the options chosen were 20 RTM and 5day.

    How can I do this? I am somewhat familiar with VBA.

    Thanks in advance for your assistance!

    Tommy

  2. #2
    NTC is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    Nov 2009
    Posts
    2,392
    right - so you need to make these 2 tables to be look up tables for your dropdowns (combo boxes).... they would be single column tables - no key - and just enter your data. We programmers have lots of these on file; weekdays, months, States, etc....they are used over and over. I refer to them as "list tables" as their function is just to feed comboboxes.

    you trigger your math in the AfterUpdate event of these. put the exact same math in both since you won't know which combobox might be enter or changed first....

    Me.TextBoxName = Me.Combo1Name * Me.Combo2Name

    obviously use the actual names not my generic ones....

    give your comboboxes a default value so it doesn't barf on an empty value when the math first gets triggered.

    hope it helps.

  3. #3
    Joe_A is offline Novice
    Windows XP Access 2007
    Join Date
    Jul 2011
    Posts
    8
    Sorry

    Thank you
    Last edited by Joe_A; 07-25-2011 at 07:44 AM.

  4. #4
    Tomfernandez1 is offline Advanced Beginner
    Windows XP Access 2003
    Join Date
    Feb 2011
    Posts
    74
    Thanks for your interest and advice. I see how the math works, but what I was hoping for was sort of a VLOOKUP or DLOOKUP that would produce a result based on data array and criteria. For example, my Table datasheet view is this:

    RTM 4day 5day 7day
    20 $100 $200 $300
    25 $200 $400 $600
    30 $300 $600 $900
    35 $400 $800 $1200
    .... ...... ....... ........

    What I want on a Form are two combo box fields. One named "RTM" the other "Workweek". RTM would show RTM increments; Workweek would be field names of the remaining fields in the Table (4day; 5day; 7day). Finally, the Form will also have a text box that when 20 is selected in RTM combo and 5day in Workweek combo, a function (VLOOKUP or DLOOKUP) would find the intersecting value $200 and display it.

    I have done this in Excel, but I'm hoping I can also perform this in Access. Can it be done??

    Again, thanks for your interest and advice!

    Tommy

  5. #5
    NTC is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    Nov 2009
    Posts
    2,392
    the way to do it is to make your 2nd combobox's table list look like this

    20 $100 4day
    20 $200 5day
    20 $300 7day
    25 $200 4day
    25 $400 5day
    25 $600 7day
    etc

    then set up this second comboboxes source to be a query of the table list above, but with a query criteria defined by the first combobox's value.....so if the user has selected 20 then the combobox choice is:

    $100 4day
    $200 5day
    $300 7day

    where the money value is the bound value of combobox 2 - - then from there you can apply your AfterUpdate math....

    Hope it helps.

  6. #6
    Tomfernandez1 is offline Advanced Beginner
    Windows XP Access 2003
    Join Date
    Feb 2011
    Posts
    74
    NTC - would you mind providing me with a database that performs this? I will be able to understand it better with an actual Form, which I can then modify to suit my needs.

    Thanks for your help!

    Tommy

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Return all fields even if lookup is empty
    By skarden in forum Access
    Replies: 2
    Last Post: 05-11-2011, 10:44 AM
  2. Collecting data via email with drop downs
    By tlyons in forum Access
    Replies: 2
    Last Post: 01-19-2011, 10:34 AM
  3. Lookup Fields
    By mikel in forum Access
    Replies: 3
    Last Post: 03-03-2010, 07:56 AM
  4. Replies: 2
    Last Post: 02-13-2010, 01:54 PM
  5. datasheet view adding fields drop-down box
    By techexpressinc in forum Access
    Replies: 2
    Last Post: 09-09-2009, 05:35 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