How to update a combo box with a query

  • Thread starter Thread starter ericb
  • Start date Start date
E

ericb

In a subform I have a combo box listing consultations.

The control source of the box is a field and the row source is a query.

Upon entering the subform the list in the combo box is ok. But when I
navigate from record to record it always gives me the same list. I can't get
it to make a new list.

How do I do this, I need to update the query every time I go from record to
record in my subform.

Thank you greatly.
 
In a subform I have a combo box listing consultations.

The control source of the box is a field and the row source is a query.

Upon entering the subform the list in the combo box is ok. But when I
navigate from record to record it always gives me the same list. I can't get
it to make a new list.

How do I do this, I need to update the query every time I go from record to
record in my subform.

Thank you greatly.

Use the form's Current event to change the Rowsource of the query.

Since you didn't post any information about the query or about the nature of
the change, it's a bit hard to be more specific than that!
 
In the OnCurrent event of the form, add code to change the rowsource query.

If len([somefield] & "") > 0 then
me.[thecombobox].rowsource = "Select * from tablename where [thisfield] =
" & [somefield]
End if
 
I'll be more specific.

The Examen table has these fields : ID_examan, REF_client, REF_consultation,
date, etc.

The Consultation table : ID_consultation, ID_client, date, etc

They are linked 1 (Consultatio.ID_consultation) to many
(Examen.REF_consultation)
and it is enforced.

When the Examen Subform is on the screen I can see the value of
Examen.REF_client.

I want to populate a combo box with the recourds of the Consultation table
that have the same Consultation.REF_client.

The Row Source of the combo box is : SELECT Consultation.ID_consultation,
Consultation.REF_client FROM Consultation WHERE
(((Consultation.REF_client)=[Forms]![Examen subform]![REF_client]));

It works fine when I open it the firts time, but when I move from record to
record the population of the box does not change, I always get the first list.

Somehow this value [Forms]![Examen subform]![REF_client] does not change
when I go from record to record.

How do I adress the Examen Subform.REF_client properly
 
Back
Top