Setting rowsource of control on subform on open, error 2424

T

Tony Vrolyk

(ignore my post a microsoft.public.access. I sent to the wrong group)

I tried searching on this but can't find a matching situation and I don't
understand why it doesn't work.

1. I am opening a popup form whose record source is set on open using a
variable passed to it with open args
2. That form has a subform. On the subform I am trying to set a rowsource of
a combo box on for open using the value of a control on the parent form as
the criteria.

I keep getting error 2424 "the expression you entered has a field control or
property name that access can't find"

The code to fill the control is like this:

Me.FundTickerSymbol.RowSource = "SELECT [fields] " _
& "FROM [tables] " _
& "WHERE (Plans_InvCo.PlanIDNumber)='" & Me.Parent!PlanIDNumber & "' [order
by]"

I have verified the spelling and existance of the controls.
FundTickerSymbol is a combo box
PlanIDNumber exists on the parent form and loads the value correctly
I have tried this on the open, load and current events of the subform.
I have triple checked my SQL.

So what am I missing? Any ideas?

Tony
 
K

Klatuu

Here is the part that makes no sense, but is true, and will drive you crazy.
When you open a form with a subform, the subform opens first, so the parent
form's properties have not yet been established.
 
E

EdA

What is the best work around for this issue? I am trying to use a combo box
on a subform that uses a control in the parent form as criteria of the
rowsource. When you open the form, it prompts to enter parameters for that
combo box. Is the only solution to set the rowsource property of the
combobox using VB code in an event?

Klatuu said:
Here is the part that makes no sense, but is true, and will drive you crazy.
When you open a form with a subform, the subform opens first, so the parent
form's properties have not yet been established.
--
Dave Hargis, Microsoft Access MVP


Tony Vrolyk said:
(ignore my post a microsoft.public.access. I sent to the wrong group)

I tried searching on this but can't find a matching situation and I don't
understand why it doesn't work.

1. I am opening a popup form whose record source is set on open using a
variable passed to it with open args
2. That form has a subform. On the subform I am trying to set a rowsource of
a combo box on for open using the value of a control on the parent form as
the criteria.

I keep getting error 2424 "the expression you entered has a field control or
property name that access can't find"

The code to fill the control is like this:

Me.FundTickerSymbol.RowSource = "SELECT [fields] " _
& "FROM [tables] " _
& "WHERE (Plans_InvCo.PlanIDNumber)='" & Me.Parent!PlanIDNumber & "' [order
by]"

I have verified the spelling and existance of the controls.
FundTickerSymbol is a combo box
PlanIDNumber exists on the parent form and loads the value correctly
I have tried this on the open, load and current events of the subform.
I have triple checked my SQL.

So what am I missing? Any ideas?

Tony
 
K

Klatuu

Try using the Load event of the main form to set the combo's row source.
Now, when addressing a control on a subform from the mainform's code module,
you have to use the correct object referencing or you will get errors.

You do not address the name of the form that is the subform directly. You
address the Form property of the subform control on the main form. The Form
property referres to the form identified in the subform control's source
object property. So the correct syntax would be:

Me!MySubFormControl.Form!MyComboBoxName.RowSource = ...

Of course, you will need to use your own names.
--
Dave Hargis, Microsoft Access MVP


EdA said:
What is the best work around for this issue? I am trying to use a combo box
on a subform that uses a control in the parent form as criteria of the
rowsource. When you open the form, it prompts to enter parameters for that
combo box. Is the only solution to set the rowsource property of the
combobox using VB code in an event?

Klatuu said:
Here is the part that makes no sense, but is true, and will drive you crazy.
When you open a form with a subform, the subform opens first, so the parent
form's properties have not yet been established.
--
Dave Hargis, Microsoft Access MVP


Tony Vrolyk said:
(ignore my post a microsoft.public.access. I sent to the wrong group)

I tried searching on this but can't find a matching situation and I don't
understand why it doesn't work.

1. I am opening a popup form whose record source is set on open using a
variable passed to it with open args
2. That form has a subform. On the subform I am trying to set a rowsource of
a combo box on for open using the value of a control on the parent form as
the criteria.

I keep getting error 2424 "the expression you entered has a field control or
property name that access can't find"

The code to fill the control is like this:

Me.FundTickerSymbol.RowSource = "SELECT [fields] " _
& "FROM [tables] " _
& "WHERE (Plans_InvCo.PlanIDNumber)='" & Me.Parent!PlanIDNumber & "' [order
by]"

I have verified the spelling and existance of the controls.
FundTickerSymbol is a combo box
PlanIDNumber exists on the parent form and loads the value correctly
I have tried this on the open, load and current events of the subform.
I have triple checked my SQL.

So what am I missing? Any ideas?

Tony
 

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