Filter SubForm Continuos form from Main Form combo box

  • Thread starter Thread starter DMUM via AccessMonster.com
  • Start date Start date
D

DMUM via AccessMonster.com

Hello, I've been searching most of the morning trying to find anything within
the forum and outside of the forum that would help me with this.

I have a Main form called - Run_import
I have a sub form called - PRSAdef_New

On my Main form, I am trying to use a combo box to filter the underlying
continuous form recordsource. Here is my code:

Set frm = Form_Run_Import

If IsNull(Me.cboPRSAType) Then
frm.RecordSource = "Test"
Else
Me!frmPRSADef_New.Form.Filter = "PRSAType = '" & Me!txtPRSAType & "'"
Me!frmPRSADef_New.Form.FilterOn = True
End If
End Sub


I keep getting a popup message that asks for thr value of PRSAType. I've
tried other combinations of code that seem to work because I get no error,
but the data in the continuos form does not update based on the selection
from the combo box. I've created filters before, but not using a subform, so
if someone could please give me the necessary syntax, I'd really appreciate
it.

Thanks

Deborah
 
DMUM said:
Hello, I've been searching most of the morning trying to find anything within
the forum and outside of the forum that would help me with this.

I have a Main form called - Run_import
I have a sub form called - PRSAdef_New

On my Main form, I am trying to use a combo box to filter the underlying
continuous form recordsource. Here is my code:

Set frm = Form_Run_Import

If IsNull(Me.cboPRSAType) Then
frm.RecordSource = "Test"
Else
Me!frmPRSADef_New.Form.Filter = "PRSAType = '" & Me!cboPRSAType & "'"
Me!frmPRSADef_New.Form.FilterOn = True
End If
End Sub

I keep getting a popup message that asks for thr value of PRSAType. I've
tried other combinations of code that seem to work because I get no error,
but the data in the continuos form does not update based on the selection
from the combo box. I've created filters before, but not using a subform, so
if someone could please give me the necessary syntax, I'd really appreciate
it.

Thanks

Deborah


By the way PRSAType is a column field on the continuous form.
 
DMUM said:
By the way PRSAType is a column field on the continuous form.


That popup message says that PRSAType is **not** a field in
the (sub)form's record sourec table/query. Perhaps there is
a slight varioation in the way you typed it in your VBA code
above, or maybe the field in the query is aliased to another
name???
 
Marshall said:
[quoted text clipped - 23 lines]
By the way PRSAType is a column field on the continuous form.

That popup message says that PRSAType is **not** a field in
the (sub)form's record sourec table/query. Perhaps there is
a slight varioation in the way you typed it in your VBA code
above, or maybe the field in the query is aliased to another
name???

Actually I found that out after I posted the question. Unfortuneatly
changing it did not correct the problem. There are only 3 fields in my query

defnum
PRSA_Definition
PRSA_Type

The query is called Test for now

The subform is called frmPRSADef_New and unless I am looking at the wrong
thing, that form name is also the same.

Any other ideas or perhaps a re-direction om my syntax.

Thank you
 
DMUM said:
[quoted text clipped - 7 lines]
above, or maybe the field in the query is aliased to another
name???

Actually I found that out after I posted the question. Unfortuneatly
changing it did not correct the problem. There are only 3 fields in my query

defnum
PRSA_Definition
PRSA_Type

The query is called Test for now

The subform is called frmPRSADef_New and unless I am looking at the wrong
thing, that form name is also the same.

Any other ideas or perhaps a re-direction om my syntax.

Thank you

I canged that particular line to: Me!frmPRSADef_New.Form.Filter = "Me!
frmPRSADef_New.PRSA_Type = '" & Me!cboPRSAType & "'"

I am still getting the same error/popup
 
DMUM said:
DMUM said:
Hello, I've been searching most of the morning trying to find anything within
the forum and outside of the forum that would help me with this.
[quoted text clipped - 7 lines]
above, or maybe the field in the query is aliased to another
name???

Actually I found that out after I posted the question. Unfortuneatly
changing it did not correct the problem. There are only 3 fields in my query

defnum
PRSA_Definition
PRSA_Type

The query is called Test for now

The subform is called frmPRSADef_New and unless I am looking at the wrong
thing, that form name is also the same.

Any other ideas or perhaps a re-direction om my syntax.

Thank you

I canged that particular line to: Me!frmPRSADef_New.Form.Filter = "Me!
frmPRSADef_New.PRSA_Type = '" & Me!cboPRSAType & "'"


I think the pop up prompt was probably a little different
this time. Try this:

Me!frmPRSADef_New.Form.Filter = _
"PRSA_Type = '" & Me!cboPRSAType & "'"

I also note that you seem to have changed the name of the
control from txtPRSAType to cboPRSAType. Don't forget that
the value of a combo box is specified in it BoundColumn
property, which may be different from what you see in the
text portion onf the combo box.
 
Thank you so much Marshall. I was dreading taking all day to get this to
work like I did yesterday.

Thank you!

Thank you!

Marshall said:
[quoted text clipped - 20 lines]
I canged that particular line to: Me!frmPRSADef_New.Form.Filter = "Me!
frmPRSADef_New.PRSA_Type = '" & Me!cboPRSAType & "'"

I think the pop up prompt was probably a little different
this time. Try this:

Me!frmPRSADef_New.Form.Filter = _
"PRSA_Type = '" & Me!cboPRSAType & "'"

I also note that you seem to have changed the name of the
control from txtPRSAType to cboPRSAType. Don't forget that
the value of a combo box is specified in it BoundColumn
property, which may be different from what you see in the
text portion onf the combo box.
 
Back
Top