Results 1 to 13 of 13
  1. #1
    Kranky is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Nov 2012
    Posts
    8

    Query records on one table from a combobox on a form that uses data from another tabl

    Hi Access Forums

    Sorry to bother you with this seemingly easy question. I have searched far and wide for the answer, including here but have had no joy.

    Goal: I have a form with 2 date boxes and 2 combo boxes (comboStaff and comboDept). All I want to do is query the main table (tblMain) using the dates and comboboxes as criteria but want the combo boxes to use a separate table to provide their values (tblStaff).

    I have the dates working fine so thats not an issue. The mechanism for comboDept will be the same as comboStaff so i'll just work with comboStaff here.

    The comboStaff will not work using the tblStaff.Staff as the source of the data. It will work if it is set to read from tblMain.StaffMember and filter the records fine.



    So basically I want to choose the dates, choose either a staff member (or none) OR a dept (or none) so that everything between the dates that meets those 0 or 1 or 2 criteria is returned.

    The current code the the query is Like [Forms]![Date_Filter]![comboStaff] & "*" on tblMain.StaffMember.

    Hope that makes sence??

    Cheers
    Kranky

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,625
    Don't understand all of that. You say you want to use tblStaff as RowSource for combobox then say that won't work?

    Want to provide db for analysis? Follow instructions at bottom of my post.
    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.

  3. #3
    Kranky is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Nov 2012
    Posts
    8
    Quote Originally Posted by June7 View Post
    Don't understand all of that. You say you want to use tblStaff as RowSource for combobox then say that won't work?
    Yes I want to use tblStaff to provide the values for the combo, then once selected find all the records with the same value in tblMain via a query. null will be all records.

    Tried to upload a copy but it exceded the 500kb limit sorry.

    Thanks

    Kranky

  4. #4
    Kranky is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Nov 2012
    Posts
    8
    Zipped and attached

    Copy.zip

  5. #5
    qa12dx is offline Competent Performer
    Windows 7 64bit Access 2007
    Join Date
    Nov 2012
    Location
    india
    Posts
    112
    use an unbound combobox. in row source use the query u want. in the lookup query reference this combobox name.

    hope it gets the joy back

  6. #6
    Kranky is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Nov 2012
    Posts
    8
    Quote Originally Posted by qa12dx View Post
    use an unbound combobox. in row source use the query u want. in the lookup query reference this combobox name.
    Did all those ( I think - done so much fiddling with it my head is spinning)

    Quote Originally Posted by qa12dx View Post
    hope it gets the joy back
    Not much joy had here today, I miss excel

    thanks for your comments - I'll go and double check everything.

  7. #7
    qa12dx is offline Competent Performer
    Windows 7 64bit Access 2007
    Join Date
    Nov 2012
    Location
    india
    Posts
    112
    post a db here. access 2007 32bit version. i'll get ur joy back. i use this type of query all the time

  8. #8
    Kranky is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Nov 2012
    Posts
    8
    Quote Originally Posted by qa12dx View Post
    post a db here. access 2007 32bit version. i'll get ur joy back. i use this type of query all the time

    the version above no good for you? Our version 2007-2010 so should be good.

  9. #9
    Kranky is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Nov 2012
    Posts
    8
    Quote Originally Posted by Kranky View Post
    the version above no good for you? Our version 2007-2010 so should be good.
    No dont do that - I changed the names of the tables to protect the innocent. So the form doesnt function anyway. Its been a long day and I'm going home for a beer (or many) in half hour. I'll worry about this disfunctional software tomorrow!

    thanks for your replies

  10. #10
    Kranky is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Nov 2012
    Posts
    8
    Quote Originally Posted by qa12dx View Post
    use an unbound combobox. in row source use the query u want. in the lookup query reference this combobox name.
    went back and did all this again and it did it
    Dont know what changed but its doing what its supposed to do.


    That is some serious joy back right there

  11. #11
    qa12dx is offline Competent Performer
    Windows 7 64bit Access 2007
    Join Date
    Nov 2012
    Location
    india
    Posts
    112
    i saw the db u uploaded. the way u done it, it's a all inclusive query.
    so if you want date and staff, say larry, it will still get u results even if larry isn't in the record set. same with dept. if u want date and see particular dept, no matter what u choose it will show u results in the date range.
    see how i do it. my qry and form has qa12x in its name.

    Copy_qa12dx.zip

  12. #12
    Kranky is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Nov 2012
    Posts
    8
    Quote Originally Posted by qa12dx View Post
    so if you want date and staff, say larry, it will still get u results even if larry isn't in the record set. same with dept. if u want date and see particular dept, no matter what u choose it will show u results in the date range.
    In the end I had it producing results the same as yours does.... however

    Quote Originally Posted by qa12dx View Post
    see how i do it. my qry and form has qa12x in its name.
    yours is a much better solution and I will alter my original file to work the same way . As they say - "more than one way to skin a cat".

    Thankyou for your time qa12dx

    regards
    Kranky

  13. #13
    qa12dx is offline Competent Performer
    Windows 7 64bit Access 2007
    Join Date
    Nov 2012
    Location
    india
    Posts
    112

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

Similar Threads

  1. Replies: 3
    Last Post: 10-02-2012, 12:25 PM
  2. Replies: 6
    Last Post: 09-10-2012, 07:19 AM
  3. Form ComboBox Filter - Select ALL records
    By jhrBanker in forum Forms
    Replies: 2
    Last Post: 08-02-2012, 08:57 AM
  4. Replies: 1
    Last Post: 09-30-2011, 02:55 AM
  5. Replies: 0
    Last Post: 02-24-2010, 12:56 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