Connecting Tech Pros Worldwide Forums | Help | Site Map

ComboBox RowSource Query

Newbie
 
Join Date: May 2009
Posts: 4
#1: Sep 22 '09
Hi Guys looking for some help please. Is a bit complex but will try to keep explination as succint as possible - here goes -

I have a Access 2007 database allocating consultants against a programme of work for a client.
I have created a form (frmEnterExpenses) to enter expenses against a programme for each consultant. The form has two combo boxes (cboProgramme and cboConsultant). I need to store the values from each box in the associated tables but have encountered a problem.
I am trying to filter the cboConsultant box so that only consultants allocated to the programme chosen in cboProgramme are shown.

My problem is that in order to show the programme, I have created a query for the row source of cboProgramme which shows the Client Name and the Programme start date.

The info feeding CboConsultants is stored in tblConsultant as ConsultantID, FistName, LastName (etc) but I want the name to be concatenated to appear in this box as FistName LastName which I have done via a query.

I cannot work out what needs to go into the rowsource for cboConsultants to allow filtering on the choice in cboProgramme and storage of ConultantPK in tblExpenses.

Sorry for the longwinded explanation but wanted to make it as clear as possible. I hope it makes sense and any help or advice you can offer is appreciated.

I have listed the tables below and the query which gathers the relevant info.

tblCollege – CollegeID (pk), CollegeName
tblProbramme – ProgrammeID (pk), StartDate, EndDate, Type, CollegeID (fk from tblCollege), PONumber, ProgStatusID (fk from tblCollegeProgrammeStatus look up table).
tblProgrammeDetail – ProgDetID (pk), ProgrammeID (fk from tblProgramme), ConsultantID (fk from tblConsultant), AreaID (fk from tblArea), NoDays
tblConsultant – CosnultantID (pk), FirstName, LastName
tblArea – AreaID (pk), area
tblSpecialism – AreaID , ConsultantID (join table for one to many relationship between consultants and areas)
tblCollegeProgrammeStatus – ProgStatusID (pk), Status (lookup table)
tblExpenses – ExpenseID, ProgrammeID (fk to tblProgramme), ConsultantID (fk to tblConsultant), Miles, Airfare, TrainFare

qryAllProgrammes –
Expand|Select|Wrap|Line Numbers
  1. SELECT tblCollege.CollegeName,
  2.        tblProgramme.ProgID,
  3.        tblProgramme.StartDate,
  4.        tblProgramme.EndDate,
  5.        tblProgramme.PONumber,
  6.        tblCollegeProgrammeStatus.Status,
  7.        tblProgrammeDetail.NumberDays,
  8.        tblArea.Area,
  9.        tblConsultant.[FirstName]+' '+ tblConsultant.[LastName] AS FullName
  10.  
  11. FROM   tblArea INNER JOIN
  12.        (tblConsultant INNER JOIN
  13.        ((tblCollege INNER JOIN
  14.        (tblCollegeProgrammeStatus INNER JOIN
  15.        tblProgramme
  16.   ON   tblCollegeProgrammeStatus.ProgStatusID=tblProgramme.StatusID)
  17.   ON   tblCollege.CollegeID=tblProgramme.CollegeID) INNER JOIN
  18.        tblProgrammeDetail
  19.   ON   tblProgramme.ProgID=tblProgrammeDetail.ProgID)
  20.   ON   tblConsultant.ConsultantID=tblProgrammeDetail.ConsultantID)
  21.   ON   tblArea.AreaID=tblProgrammeDetail.AreaID;
Thank you for taking the time to read this
best answer - posted by NeoPa
Quote:

Originally Posted by 20028431 View Post

I cannot work out what needs to go into the rowsource for cboConsultants to allow filtering on the choice in cboProgramme and storage of ConultantPK in tblExpenses.

Let me first make a quick point about hard this is to read through while concentrating on trying to understand what is meant. Typos are fine when messaging your friends, but when asking technical questions they get in the way big time. Please read through your question more carefully before submitting in future, especially when it's as involved as this clearly is.

That out of the way, it seems you are trying to filter a ComboBox within your form, and wanting to store the returned value in the underlying record.

Filtering ComboBoxes is not something you can do by applying a filter string (as you can with forms and reports for instance). You will need to determine what the .RowSource needs to be to effect the desired results and update it commensurately.

For saving the result away in the underlying record you need to ensure that the ComboBox control is bound and that the value returned (reflected by .BoundColumn) is the one you require.

As an aside, did you know that + and & are not exactly equivalent when dealing with string concatenation (Using "&" and "+" in WHERE Clause)?

NeoPa's Avatar
Administrator
 
Join Date: Oct 2006
Location: London - UK
Posts: 15,730
#2: Sep 22 '09

re: ComboBox RowSource Query


Quote:

Originally Posted by 20028431 View Post

I cannot work out what needs to go into the rowsource for cboConsultants to allow filtering on the choice in cboProgramme and storage of ConultantPK in tblExpenses.

Let me first make a quick point about hard this is to read through while concentrating on trying to understand what is meant. Typos are fine when messaging your friends, but when asking technical questions they get in the way big time. Please read through your question more carefully before submitting in future, especially when it's as involved as this clearly is.

That out of the way, it seems you are trying to filter a ComboBox within your form, and wanting to store the returned value in the underlying record.

Filtering ComboBoxes is not something you can do by applying a filter string (as you can with forms and reports for instance). You will need to determine what the .RowSource needs to be to effect the desired results and update it commensurately.

For saving the result away in the underlying record you need to ensure that the ComboBox control is bound and that the value returned (reflected by .BoundColumn) is the one you require.

As an aside, did you know that + and & are not exactly equivalent when dealing with string concatenation (Using "&" and "+" in WHERE Clause)?
Delerna's Avatar
Expert
 
Join Date: Jan 2008
Location: Sydney
Posts: 790
#3: Sep 22 '09

re: ComboBox RowSource Query


You want to select a value in one combobox (cboProgram) and have the values in the second combobox (cboConsultants) to change and display only the consultants that are allowed for the chosen program.

Sounds similar to this
filter drop down list based on the value of another field - pls help with syntax

there is a database attached to post number 7. Maybe that will help you?
Reply