filtering on subform

J

Jeannie

I have an embedded form that holds two types of records, closed (=1) or open
(=2). I need a filter to display either closed, open or both. The
ApplyFilter Macro doesn't work.

Your help is much appreciated!
 
K

Klatuu

If you are saying you want to filter your subform records from a control on
the main form, I would suggest an option group control with 3 buttons on it.
First button labled "Closed" with an Option Value of 1, Second button labled
"Open" with an Option Value of 2, Third button labled "All" with an Option
Value of 3

Then use the option group control's After Upate event to do the filtering:

If Me.opgFilter = 3 Then
With Me.MySubformControlName.Form
.Filter = vbNullstring
.FilterOn = False
End With
Else
With Me.MySubformControlName.Form
.Filter = "[RecordType] = " & Me.opgFilter
.FilterOn = True
End With
End If
 
J

Jeannie

I have substituted my object names, but don't understand what should go into
"[RecordType]. When I reference the field on the subform that contains the
status field I get a parameter message when I try to open the form. What am
I doing wrong?

Here is my adapted code:
If Me.Frame46 = 3 Then
With Me.[MM_Processing PO's_Sub Detail].Form
..Filter = vbNullString
..FilterOn = False
End With
Else
With Me.[MM_Processing PO's_Sub Detail].Form
..Filter = "[RecordType] = " & Me.Frame46
..FilterOn = True
End With
End If


Klatuu said:
If you are saying you want to filter your subform records from a control on
the main form, I would suggest an option group control with 3 buttons on it.
First button labled "Closed" with an Option Value of 1, Second button labled
"Open" with an Option Value of 2, Third button labled "All" with an Option
Value of 3

Then use the option group control's After Upate event to do the filtering:

If Me.opgFilter = 3 Then
With Me.MySubformControlName.Form
.Filter = vbNullstring
.FilterOn = False
End With
Else
With Me.MySubformControlName.Form
.Filter = "[RecordType] = " & Me.opgFilter
.FilterOn = True
End With
End If

--
Dave Hargis, Microsoft Access MVP


Jeannie said:
I have an embedded form that holds two types of records, closed (=1) or open
(=2). I need a filter to display either closed, open or both. The
ApplyFilter Macro doesn't work.

Your help is much appreciated!
 
K

Klatuu

This line:
..Filter = "[RecordType] = " & Me.Frame46
is most likely your problem
RecordType should be a field in your form's recordset.

--
Dave Hargis, Microsoft Access MVP


Jeannie said:
I have substituted my object names, but don't understand what should go into
"[RecordType]. When I reference the field on the subform that contains the
status field I get a parameter message when I try to open the form. What am
I doing wrong?

Here is my adapted code:
If Me.Frame46 = 3 Then
With Me.[MM_Processing PO's_Sub Detail].Form
.Filter = vbNullString
.FilterOn = False
End With
Else
With Me.[MM_Processing PO's_Sub Detail].Form
.Filter = "[RecordType] = " & Me.Frame46
.FilterOn = True
End With
End If


Klatuu said:
If you are saying you want to filter your subform records from a control on
the main form, I would suggest an option group control with 3 buttons on it.
First button labled "Closed" with an Option Value of 1, Second button labled
"Open" with an Option Value of 2, Third button labled "All" with an Option
Value of 3

Then use the option group control's After Upate event to do the filtering:

If Me.opgFilter = 3 Then
With Me.MySubformControlName.Form
.Filter = vbNullstring
.FilterOn = False
End With
Else
With Me.MySubformControlName.Form
.Filter = "[RecordType] = " & Me.opgFilter
.FilterOn = True
End With
End If

--
Dave Hargis, Microsoft Access MVP


Jeannie said:
I have an embedded form that holds two types of records, closed (=1) or open
(=2). I need a filter to display either closed, open or both. The
ApplyFilter Macro doesn't work.

Your help is much appreciated!
 
J

Jeannie

I did attempt to reference the field before my first reply. Since the field
is located on an embedded form, do I reference the hierarchy of forms? e.g.
masterform!detailform.fieldname?

Klatuu said:
This line:
.Filter = "[RecordType] = " & Me.Frame46
is most likely your problem
RecordType should be a field in your form's recordset.

--
Dave Hargis, Microsoft Access MVP


Jeannie said:
I have substituted my object names, but don't understand what should go into
"[RecordType]. When I reference the field on the subform that contains the
status field I get a parameter message when I try to open the form. What am
I doing wrong?

Here is my adapted code:
If Me.Frame46 = 3 Then
With Me.[MM_Processing PO's_Sub Detail].Form
.Filter = vbNullString
.FilterOn = False
End With
Else
With Me.[MM_Processing PO's_Sub Detail].Form
.Filter = "[RecordType] = " & Me.Frame46
.FilterOn = True
End With
End If


Klatuu said:
If you are saying you want to filter your subform records from a control on
the main form, I would suggest an option group control with 3 buttons on it.
First button labled "Closed" with an Option Value of 1, Second button labled
"Open" with an Option Value of 2, Third button labled "All" with an Option
Value of 3

Then use the option group control's After Upate event to do the filtering:

If Me.opgFilter = 3 Then
With Me.MySubformControlName.Form
.Filter = vbNullstring
.FilterOn = False
End With
Else
With Me.MySubformControlName.Form
.Filter = "[RecordType] = " & Me.opgFilter
.FilterOn = True
End With
End If

--
Dave Hargis, Microsoft Access MVP


:

I have an embedded form that holds two types of records, closed (=1) or open
(=2). I need a filter to display either closed, open or both. The
ApplyFilter Macro doesn't work.

Your help is much appreciated!
 
K

Klatuu

[RecordType] has to be some field in the subform's recordset. You are
filtering the subform.

I assume the option group is on the mainform. Is that correct?

--
Dave Hargis, Microsoft Access MVP


Jeannie said:
I did attempt to reference the field before my first reply. Since the field
is located on an embedded form, do I reference the hierarchy of forms? e.g.
masterform!detailform.fieldname?

Klatuu said:
This line:
.Filter = "[RecordType] = " & Me.Frame46
is most likely your problem
RecordType should be a field in your form's recordset.

--
Dave Hargis, Microsoft Access MVP


Jeannie said:
I have substituted my object names, but don't understand what should go into
"[RecordType]. When I reference the field on the subform that contains the
status field I get a parameter message when I try to open the form. What am
I doing wrong?

Here is my adapted code:
If Me.Frame46 = 3 Then
With Me.[MM_Processing PO's_Sub Detail].Form
.Filter = vbNullString
.FilterOn = False
End With
Else
With Me.[MM_Processing PO's_Sub Detail].Form
.Filter = "[RecordType] = " & Me.Frame46
.FilterOn = True
End With
End If


:

If you are saying you want to filter your subform records from a control on
the main form, I would suggest an option group control with 3 buttons on it.
First button labled "Closed" with an Option Value of 1, Second button labled
"Open" with an Option Value of 2, Third button labled "All" with an Option
Value of 3

Then use the option group control's After Upate event to do the filtering:

If Me.opgFilter = 3 Then
With Me.MySubformControlName.Form
.Filter = vbNullstring
.FilterOn = False
End With
Else
With Me.MySubformControlName.Form
.Filter = "[RecordType] = " & Me.opgFilter
.FilterOn = True
End With
End If

--
Dave Hargis, Microsoft Access MVP


:

I have an embedded form that holds two types of records, closed (=1) or open
(=2). I need a filter to display either closed, open or both. The
ApplyFilter Macro doesn't work.

Your help is much appreciated!
 
J

Jeannie

Yes, the option group is on the mainform and the records to be filtered are
[RecordType] has to be some field in the subform's recordset. You are
filtering the subform.

I assume the option group is on the mainform. Is that correct?

--
Dave Hargis, Microsoft Access MVP


Jeannie said:
I did attempt to reference the field before my first reply. Since the field
is located on an embedded form, do I reference the hierarchy of forms? e.g.
masterform!detailform.fieldname?

Klatuu said:
This line:
.Filter = "[RecordType] = " & Me.Frame46
is most likely your problem
RecordType should be a field in your form's recordset.

--
Dave Hargis, Microsoft Access MVP


:

I have substituted my object names, but don't understand what should go into
"[RecordType]. When I reference the field on the subform that contains the
status field I get a parameter message when I try to open the form. What am
I doing wrong?

Here is my adapted code:
If Me.Frame46 = 3 Then
With Me.[MM_Processing PO's_Sub Detail].Form
.Filter = vbNullString
.FilterOn = False
End With
Else
With Me.[MM_Processing PO's_Sub Detail].Form
.Filter = "[RecordType] = " & Me.Frame46
.FilterOn = True
End With
End If


:

If you are saying you want to filter your subform records from a control on
the main form, I would suggest an option group control with 3 buttons on it.
First button labled "Closed" with an Option Value of 1, Second button labled
"Open" with an Option Value of 2, Third button labled "All" with an Option
Value of 3

Then use the option group control's After Upate event to do the filtering:

If Me.opgFilter = 3 Then
With Me.MySubformControlName.Form
.Filter = vbNullstring
.FilterOn = False
End With
Else
With Me.MySubformControlName.Form
.Filter = "[RecordType] = " & Me.opgFilter
.FilterOn = True
End With
End If

--
Dave Hargis, Microsoft Access MVP


:

I have an embedded form that holds two types of records, closed (=1) or open
(=2). I need a filter to display either closed, open or both. The
ApplyFilter Macro doesn't work.

Your help is much appreciated!
 
K

Klatuu

the [RecordType] is just a name I used as an example.
You need to use the actual field name in the subform's recordset that you
want to filter on. The syntax I originally posted should work for that.
--
Dave Hargis, Microsoft Access MVP


Jeannie said:
Yes, the option group is on the mainform and the records to be filtered are
[RecordType] has to be some field in the subform's recordset. You are
filtering the subform.

I assume the option group is on the mainform. Is that correct?

--
Dave Hargis, Microsoft Access MVP


Jeannie said:
I did attempt to reference the field before my first reply. Since the field
is located on an embedded form, do I reference the hierarchy of forms? e.g.
masterform!detailform.fieldname?

:

This line:
.Filter = "[RecordType] = " & Me.Frame46
is most likely your problem
RecordType should be a field in your form's recordset.

--
Dave Hargis, Microsoft Access MVP


:

I have substituted my object names, but don't understand what should go into
"[RecordType]. When I reference the field on the subform that contains the
status field I get a parameter message when I try to open the form. What am
I doing wrong?

Here is my adapted code:
If Me.Frame46 = 3 Then
With Me.[MM_Processing PO's_Sub Detail].Form
.Filter = vbNullString
.FilterOn = False
End With
Else
With Me.[MM_Processing PO's_Sub Detail].Form
.Filter = "[RecordType] = " & Me.Frame46
.FilterOn = True
End With
End If


:

If you are saying you want to filter your subform records from a control on
the main form, I would suggest an option group control with 3 buttons on it.
First button labled "Closed" with an Option Value of 1, Second button labled
"Open" with an Option Value of 2, Third button labled "All" with an Option
Value of 3

Then use the option group control's After Upate event to do the filtering:

If Me.opgFilter = 3 Then
With Me.MySubformControlName.Form
.Filter = vbNullstring
.FilterOn = False
End With
Else
With Me.MySubformControlName.Form
.Filter = "[RecordType] = " & Me.opgFilter
.FilterOn = True
End With
End If

--
Dave Hargis, Microsoft Access MVP


:

I have an embedded form that holds two types of records, closed (=1) or open
(=2). I need a filter to display either closed, open or both. The
ApplyFilter Macro doesn't work.

Your help is much appreciated!
 

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