Results 1 to 2 of 2
  1. #1
    rabia is offline Advanced Beginner
    Windows 10 Access 2013 64bit
    Join Date
    Aug 2017
    Posts
    38

    Search age from the combo box and invoke records in other form

    I have a search form1 with a combo box of range of age.
    "Under 18
    18-25


    26-35
    Over 35"
    Once the user chooses from one of the options, another form2 should open up with all the matching ages. I've created a text field in form2 which calculates the age based on the date of birth field from the table.
    I used the macro and stated if combo box of age from form1 is "Under 18" then I'm opening a new form2 and in the where clause trying to get all the records that are less than 18 years old.
    My concern is that age in form2 will get calculated only once its open, so it will not work. Should I create a query and calculate age, then use that query in the where clause.
    Please help me out here. I'm totally new to the macros and the coding. Thanks

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,815
    By 'macro' do you mean VBA or actually a macro?

    The WHERE ARGUMENT of OpenForm command can calculate the age range values and apply the 'under 18' parameter.

    But why not construct a field in query that calculates values so field is conveniently available for referencing?

    Asked and answered in https://www.accessforums.net/showthread.php?t=67535 and https://www.accessforums.net/showthread.php?t=67521
    and https://www.accessforums.net/showthread.php?t=67523
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

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

Similar Threads

  1. Replies: 1
    Last Post: 07-25-2016, 05:24 AM
  2. Replies: 6
    Last Post: 08-08-2013, 01:00 PM
  3. Replies: 7
    Last Post: 08-08-2012, 03:28 PM
  4. Replies: 1
    Last Post: 04-20-2012, 03:16 AM
  5. Recalling Records from a Combo search
    By Dreamcatcher in forum Forms
    Replies: 0
    Last Post: 08-18-2008, 07:33 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