Results 1 to 5 of 5
  1. #1
    dapoole is offline Novice
    Windows 7 32bit Access 2003
    Join Date
    Oct 2010
    Posts
    11

    Subform Combobox To Only List Specific Values

    Hi there,



    I have an Employee's Development Objective main form , which has a subform that contains a combobox that lists all 'Job Titles' and 'Job Objectives' within the company, say such as:

    Code:
    IT Manager, Create Spreadsheets
    IT Manager, Manage Staff
    SQL DBA, Create Databases
    SQL DBA, Create Spreadsheets
    Managing Director, Manage Finance
    Managing Director, Manage Staff
    How do I get the subform combo box to ONLY display the Job Titles and Job Objectives specific to the Employees known Job Title? The combobox Row Source is presently:

    Code:
    SELECT qryJobObjectiveDetails.jobObjID, qryJobObjectiveDetails.jobTitle, qryJobObjectiveDetails.objective 
    FROM qryJobObjectiveDetails 
    ORDER BY [jobTitle], [objective];
    The main form has a jobID number specific to the Employees job title.

    TIA

  2. #2
    fredz is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Feb 2014
    Posts
    19
    1. Add a "where" clause to your rowsource query.
    2. Add a combobox.requery to the OnCurrent event of your form.
    Fred

  3. #3
    dapoole is offline Novice
    Windows 7 32bit Access 2003
    Join Date
    Oct 2010
    Posts
    11
    Thanks but how do I write the query to include the jobID from the main form? And if my combobox is called cboxJobList how do I write the combobox requery?

  4. #4
    fredz is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Feb 2014
    Posts
    19
    You can make both changes in the Subform OnCurrent Event with something like (caution for linewrap):
    (Assuming jobObjID is a numeric field)

    Me.cboxJobList.RowSource = "SELECT jobObjID, jobTitle, objective FROM qryJobObjectiveDetails WHERE jobObjID=" & Me.Parent.JobID & " ORDER BY [jobTitle], [objective];"

    Me.cboxJobList.Requery

    Fred

  5. #5
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,626
    Or can put the SQL directly in the combobox RowSource and the VBA is only needed to Requery.

    SELECT jobObjID, jobTitle, objective FROM qryJobObjectiveDetails WHERE jobObjID=[Parent].[JobID] ORDER BY [jobTitle], [objective];
    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: 12-10-2013, 03:15 PM
  2. Replies: 5
    Last Post: 05-17-2013, 10:45 AM
  3. Replies: 1
    Last Post: 09-06-2011, 01:47 PM
  4. Replies: 0
    Last Post: 08-24-2010, 06:38 PM
  5. Replies: 0
    Last Post: 12-16-2009, 01:14 PM

Tags for this Thread

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