combobox filter problem in subforms

E

eggyong

i've created a form sbfStyleOperation with two combo boxes cboMachine and
cboOperationID. cboMachine contains machine types and cboOperationID contains
the "filtered" operations that uses the chosen machine at cboMachine. I got
this working fine by using Requery macro in the AfterUpdate event at
cboMachine and SELECT,FROM,WHERE at the row source of cboOperationID.

SELECT tblSOL.OperationID, tblSOL.OperationDescription FROM tblSOL WHERE
tblSOL.Machine=Forms!sbfStyleOperation!cboMachine;

Now, the problem is when i attached sbfStyleOperation as a subform to a main
form, after i select a machine in cboMachine, a messagebox pops asking me to
enter a parameter value for "Forms!sbfStyleOperation!cboMachine"

Hope somebody points me in the right direction. Thank you in advance
 
G

Guest

If you place the sbfStyleOperation as a subform you should reference the main
form as well. S try the following in your parameter:

SELECT tblSOL.OperationID, tblSOL.OperationDescription FROM tblSOL WHERE
tblSOL.Machine=Forms![MainformName]!sbfStyleOperation!cboMachine;

where [mainformname]=name of the Main form

That should do the trick.

Maurice
 
M

Marshall Barton

eggyong said:
i've created a form sbfStyleOperation with two combo boxes cboMachine and
cboOperationID. cboMachine contains machine types and cboOperationID contains
the "filtered" operations that uses the chosen machine at cboMachine. I got
this working fine by using Requery macro in the AfterUpdate event at
cboMachine and SELECT,FROM,WHERE at the row source of cboOperationID.

SELECT tblSOL.OperationID, tblSOL.OperationDescription FROM tblSOL WHERE
tblSOL.Machine=Forms!sbfStyleOperation!cboMachine;

Now, the problem is when i attached sbfStyleOperation as a subform to a main
form, after i select a machine in cboMachine, a messagebox pops asking me to
enter a parameter value for "Forms!sbfStyleOperation!cboMachine"


A different way that is independent of the main form -
subform issue is to set the RowSource instead of using
requery.

Me.cboOperationID.RowSource = _
"SELECT OperationID, OperationDescription " _
& "FROM tblSOL " _
& "WHERE Machine=" & Me.cboMachine

If you also have a requery in the form's Current event,
replace that too.
 

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