Query in a sub form

T

Tony

Hello,

I have a form with a subform in Access 2003. One of the fields in the
subform is called categoryid. I am trying to base a combobox on a
query which looks up the value of the categoryid of the current record
on the subform and then displays an appropriate list for that
categoryid in the combobox.

In the query I use the following line in the criteria [Forms]!
[TblOrderDetails1]![TblItemOrderDetails Subform].[Form]![CategoryID]

However, this query only works for the first record in the subform.
Regardless of which record the combobox is in, it always looks up the
CategoryID of the first record in the subform.

Does anyone have any ideas? this has been puzzling me for days.

Thank you,

Tony
 
D

Dirk Goldgar

Tony said:
Hello,

I have a form with a subform in Access 2003. One of the fields in the
subform is called categoryid. I am trying to base a combobox on a
query which looks up the value of the categoryid of the current record
on the subform and then displays an appropriate list for that
categoryid in the combobox.

In the query I use the following line in the criteria [Forms]!
[TblOrderDetails1]![TblItemOrderDetails Subform].[Form]![CategoryID]

However, this query only works for the first record in the subform.
Regardless of which record the combobox is in, it always looks up the
CategoryID of the first record in the subform.

Does anyone have any ideas? this has been puzzling me for days.


You have to requery the combo box every time you move to a new record on the
subform; that is, in the subform's Current event. You also have to requery
it whenever you change the value of the CategoryID field on the subform;
that is, in the CategoryID control's AfterUpdate event.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top