apply filter to master form

G

Guest

I have a main form [frm_main] that is based on the table with all of the
basic client data. Needless to say, I have built the entire db around this.
Anyway, all clients can be either active or inactive. This main form has a
checkbox for active/inactive. I'd like to make a small subform in the
swithboard with a yes/no box to show active (yes/no) and inactive (yes/no)
clients.

I could do it with a query (an redirecting all form controls to the query
rather than the main table) but that seems like a hell of a lot of work. Is
there anyway to simply filter the forms based on the vaules of the subform in
the swithboard? the subfrom would be called LU_ShowActive with 2 fields;
value (active/inactive) and status (yes/no checkbox).

Hope this is possible. Thanks. Ian.
 
A

Allen Browne

It might be easier to do this just by adding an unbound option group to the
Header section of the form.

The group would have 3 buttons for Active, Inactive, and All respectively,
so it looked like this:
[o] Active [ ] Inactive [ ] All

Set the group's AfterUpdate property to:
[Event Procedure]
Click the Build button (...) beside it.
Access opens the code window.
Set up the code like the example below:

Private Sub grpFilterActive_AfterUpdate()
If Me.Dirty Then Me.Dirty = False
Select Case Me.grpFilterActive.Value
Case 1
Me.Filter = "Inactive = False"
Me.FilterOn = True
Case 2
Me.Filter = "Inactive = True"
Me.FilterOn = True
Case Else
Me.FilterOn = False
End Select
End Sub

Additional hints
===========
1. Set the Default Value of the group to 1, so it defaults to active
clients.

2. Add this line to the form's On Open event procedure so it opens filtered:
Call grpFilterActive_AfterUpdate
 
G

Guest

Thanks again Allen. I put one option group button in the header called
labelled "view inactives" (Option80). Sorry but I didn't understand how to
apply the code exactly What do I do though to define the grpFilter (e.g.
when grpFilture is on only show the records in [main] where [active] = true?).

Ian




Allen Browne said:
It might be easier to do this just by adding an unbound option group to the
Header section of the form.

The group would have 3 buttons for Active, Inactive, and All respectively,
so it looked like this:
[o] Active [ ] Inactive [ ] All

Set the group's AfterUpdate property to:
[Event Procedure]
Click the Build button (...) beside it.
Access opens the code window.
Set up the code like the example below:

Private Sub grpFilterActive_AfterUpdate()
If Me.Dirty Then Me.Dirty = False
Select Case Me.grpFilterActive.Value
Case 1
Me.Filter = "Inactive = False"
Me.FilterOn = True
Case 2
Me.Filter = "Inactive = True"
Me.FilterOn = True
Case Else
Me.FilterOn = False
End Select
End Sub

Additional hints
===========
1. Set the Default Value of the group to 1, so it defaults to active
clients.

2. Add this line to the form's On Open event procedure so it opens filtered:
Call grpFilterActive_AfterUpdate

--
Allen Browne - Microsoft MVP. Perth, Western Australia

Reply to group, rather than allenbrowne at mvps dot org.

Ian said:
I have a main form [frm_main] that is based on the table with all of the
basic client data. Needless to say, I have built the entire db around
this.
Anyway, all clients can be either active or inactive. This main form has
a
checkbox for active/inactive. I'd like to make a small subform in the
swithboard with a yes/no box to show active (yes/no) and inactive (yes/no)
clients.

I could do it with a query (an redirecting all form controls to the query
rather than the main table) but that seems like a hell of a lot of work.
Is
there anyway to simply filter the forms based on the vaules of the subform
in
the swithboard? the subfrom would be called LU_ShowActive with 2 fields;
value (active/inactive) and status (yes/no checkbox).

Hope this is possible. Thanks. Ian.
 
A

Allen Browne

If you name your option group "grpFilterActive", and your yes/no field is
named "Inactive", you can use the code as it is.

If your names are different, change each time those names occur in the code.
And add square brackets around the names if they contain spaces, e.g.:
Select Case Me.[view inactives].Value

--
Allen Browne - Microsoft MVP. Perth, Western Australia

Reply to group, rather than allenbrowne at mvps dot org.

Ian said:
Thanks again Allen. I put one option group button in the header called
labelled "view inactives" (Option80). Sorry but I didn't understand how
to
apply the code exactly What do I do though to define the grpFilter (e.g.
when grpFilture is on only show the records in [main] where [active] =
true?).

Ian




Allen Browne said:
It might be easier to do this just by adding an unbound option group to
the
Header section of the form.

The group would have 3 buttons for Active, Inactive, and All
respectively,
so it looked like this:
[o] Active [ ] Inactive [ ] All

Set the group's AfterUpdate property to:
[Event Procedure]
Click the Build button (...) beside it.
Access opens the code window.
Set up the code like the example below:

Private Sub grpFilterActive_AfterUpdate()
If Me.Dirty Then Me.Dirty = False
Select Case Me.grpFilterActive.Value
Case 1
Me.Filter = "Inactive = False"
Me.FilterOn = True
Case 2
Me.Filter = "Inactive = True"
Me.FilterOn = True
Case Else
Me.FilterOn = False
End Select
End Sub

Additional hints
===========
1. Set the Default Value of the group to 1, so it defaults to active
clients.

2. Add this line to the form's On Open event procedure so it opens
filtered:
Call grpFilterActive_AfterUpdate

--
Allen Browne - Microsoft MVP. Perth, Western Australia

Reply to group, rather than allenbrowne at mvps dot org.

Ian said:
I have a main form [frm_main] that is based on the table with all of
the
basic client data. Needless to say, I have built the entire db around
this.
Anyway, all clients can be either active or inactive. This main form
has
a
checkbox for active/inactive. I'd like to make a small subform in the
swithboard with a yes/no box to show active (yes/no) and inactive
(yes/no)
clients.

I could do it with a query (an redirecting all form controls to the
query
rather than the main table) but that seems like a hell of a lot of
work.
Is
there anyway to simply filter the forms based on the vaules of the
subform
in
the swithboard? the subfrom would be called LU_ShowActive with 2
fields;
value (active/inactive) and status (yes/no checkbox).

Hope this is possible. Thanks. Ian.
 
G

Guest

not sure what i'm doing wrong but it's not doing anything:
the View Inactive option box is called grpFilterActive
The checkbox in the main form is called active
I put this code in the grpfilteractive after_update() field

Private Sub grpFilterActive_AfterUpdate()
If Me.Dirty Then Me.Dirty = False
Select Case Me.grpFilterActive.Value
Case 1
Me.Filter = "active = False"
Me.FilterOn = True
Case 2
Me.Filter = "active = True"
Me.FilterOn = True
Case Else
Me.FilterOn = False
End Select

End Sub
And the code in the main forms on open event field.

If the option group is on no filter should be applied, if the option group
is off it should filter only the forms with active set to true??

thx.


Allen Browne said:
If you name your option group "grpFilterActive", and your yes/no field is
named "Inactive", you can use the code as it is.

If your names are different, change each time those names occur in the code.
And add square brackets around the names if they contain spaces, e.g.:
Select Case Me.[view inactives].Value

--
Allen Browne - Microsoft MVP. Perth, Western Australia

Reply to group, rather than allenbrowne at mvps dot org.

Ian said:
Thanks again Allen. I put one option group button in the header called
labelled "view inactives" (Option80). Sorry but I didn't understand how
to
apply the code exactly What do I do though to define the grpFilter (e.g.
when grpFilture is on only show the records in [main] where [active] =
true?).

Ian




Allen Browne said:
It might be easier to do this just by adding an unbound option group to
the
Header section of the form.

The group would have 3 buttons for Active, Inactive, and All
respectively,
so it looked like this:
[o] Active [ ] Inactive [ ] All

Set the group's AfterUpdate property to:
[Event Procedure]
Click the Build button (...) beside it.
Access opens the code window.
Set up the code like the example below:

Private Sub grpFilterActive_AfterUpdate()
If Me.Dirty Then Me.Dirty = False
Select Case Me.grpFilterActive.Value
Case 1
Me.Filter = "Inactive = False"
Me.FilterOn = True
Case 2
Me.Filter = "Inactive = True"
Me.FilterOn = True
Case Else
Me.FilterOn = False
End Select
End Sub

Additional hints
===========
1. Set the Default Value of the group to 1, so it defaults to active
clients.

2. Add this line to the form's On Open event procedure so it opens
filtered:
Call grpFilterActive_AfterUpdate

--
Allen Browne - Microsoft MVP. Perth, Western Australia

Reply to group, rather than allenbrowne at mvps dot org.

I have a main form [frm_main] that is based on the table with all of
the
basic client data. Needless to say, I have built the entire db around
this.
Anyway, all clients can be either active or inactive. This main form
has
a
checkbox for active/inactive. I'd like to make a small subform in the
swithboard with a yes/no box to show active (yes/no) and inactive
(yes/no)
clients.

I could do it with a query (an redirecting all form controls to the
query
rather than the main table) but that seems like a hell of a lot of
work.
Is
there anyway to simply filter the forms based on the vaules of the
subform
in
the swithboard? the subfrom would be called LU_ShowActive with 2
fields;
value (active/inactive) and status (yes/no checkbox).

Hope this is possible. Thanks. Ian.
 
G

Guest

I tried this code but it just didn't work (although I think I like the
logic). The option groups is "View Inactives" which is called grpfilteractive
Private Sub grpFilterActive_AfterUpdate()
If Me.Dirty Then Me.Dirty = False
If Me.grpFilterActive = True Then
Me.Filter = "Active = False"
Me.FilterOn = False
If Me.grpFilterActive = False Then
Me.Filter = "Active = False"
Me.FilterOn = True
End Select


End Sub

Ian said:
not sure what i'm doing wrong but it's not doing anything:
the View Inactive option box is called grpFilterActive
The checkbox in the main form is called active
I put this code in the grpfilteractive after_update() field

Private Sub grpFilterActive_AfterUpdate()
If Me.Dirty Then Me.Dirty = False
Select Case Me.grpFilterActive.Value
Case 1
Me.Filter = "active = False"
Me.FilterOn = True
Case 2
Me.Filter = "active = True"
Me.FilterOn = True
Case Else
Me.FilterOn = False
End Select

End Sub
And the code in the main forms on open event field.

If the option group is on no filter should be applied, if the option group
is off it should filter only the forms with active set to true??

thx.


Allen Browne said:
If you name your option group "grpFilterActive", and your yes/no field is
named "Inactive", you can use the code as it is.

If your names are different, change each time those names occur in the code.
And add square brackets around the names if they contain spaces, e.g.:
Select Case Me.[view inactives].Value

--
Allen Browne - Microsoft MVP. Perth, Western Australia

Reply to group, rather than allenbrowne at mvps dot org.

Ian said:
Thanks again Allen. I put one option group button in the header called
labelled "view inactives" (Option80). Sorry but I didn't understand how
to
apply the code exactly What do I do though to define the grpFilter (e.g.
when grpFilture is on only show the records in [main] where [active] =
true?).

Ian




:

It might be easier to do this just by adding an unbound option group to
the
Header section of the form.

The group would have 3 buttons for Active, Inactive, and All
respectively,
so it looked like this:
[o] Active [ ] Inactive [ ] All

Set the group's AfterUpdate property to:
[Event Procedure]
Click the Build button (...) beside it.
Access opens the code window.
Set up the code like the example below:

Private Sub grpFilterActive_AfterUpdate()
If Me.Dirty Then Me.Dirty = False
Select Case Me.grpFilterActive.Value
Case 1
Me.Filter = "Inactive = False"
Me.FilterOn = True
Case 2
Me.Filter = "Inactive = True"
Me.FilterOn = True
Case Else
Me.FilterOn = False
End Select
End Sub

Additional hints
===========
1. Set the Default Value of the group to 1, so it defaults to active
clients.

2. Add this line to the form's On Open event procedure so it opens
filtered:
Call grpFilterActive_AfterUpdate

--
Allen Browne - Microsoft MVP. Perth, Western Australia

Reply to group, rather than allenbrowne at mvps dot org.

I have a main form [frm_main] that is based on the table with all of
the
basic client data. Needless to say, I have built the entire db around
this.
Anyway, all clients can be either active or inactive. This main form
has
a
checkbox for active/inactive. I'd like to make a small subform in the
swithboard with a yes/no box to show active (yes/no) and inactive
(yes/no)
clients.

I could do it with a query (an redirecting all form controls to the
query
rather than the main table) but that seems like a hell of a lot of
work.
Is
there anyway to simply filter the forms based on the vaules of the
subform
in
the swithboard? the subfrom would be called LU_ShowActive with 2
fields;
value (active/inactive) and status (yes/no checkbox).

Hope this is possible. Thanks. Ian.
 
A

Allen Browne

Is the name of the option group [View inactives], or is it grpfilteractive?

Does the code compile? (Compile on Debug menu, in code window.)

What error message do you get?

--
Allen Browne - Microsoft MVP. Perth, Western Australia

Reply to group, rather than allenbrowne at mvps dot org.

Ian said:
I tried this code but it just didn't work (although I think I like the
logic). The option groups is "View Inactives" which is called
grpfilteractive
Private Sub grpFilterActive_AfterUpdate()
If Me.Dirty Then Me.Dirty = False
If Me.grpFilterActive = True Then
Me.Filter = "Active = False"
Me.FilterOn = False
If Me.grpFilterActive = False Then
Me.Filter = "Active = False"
Me.FilterOn = True
End Select


End Sub

Ian said:
not sure what i'm doing wrong but it's not doing anything:
the View Inactive option box is called grpFilterActive
The checkbox in the main form is called active
I put this code in the grpfilteractive after_update() field

Private Sub grpFilterActive_AfterUpdate()
If Me.Dirty Then Me.Dirty = False
Select Case Me.grpFilterActive.Value
Case 1
Me.Filter = "active = False"
Me.FilterOn = True
Case 2
Me.Filter = "active = True"
Me.FilterOn = True
Case Else
Me.FilterOn = False
End Select

End Sub
And the code in the main forms on open event field.

If the option group is on no filter should be applied, if the option
group
is off it should filter only the forms with active set to true??

thx.


Allen Browne said:
If you name your option group "grpFilterActive", and your yes/no field
is
named "Inactive", you can use the code as it is.

If your names are different, change each time those names occur in the
code.
And add square brackets around the names if they contain spaces, e.g.:
Select Case Me.[view inactives].Value

--
Allen Browne - Microsoft MVP. Perth, Western Australia

Reply to group, rather than allenbrowne at mvps dot org.

Thanks again Allen. I put one option group button in the header
called
labelled "view inactives" (Option80). Sorry but I didn't understand
how
to
apply the code exactly What do I do though to define the grpFilter
(e.g.
when grpFilture is on only show the records in [main] where [active]
=
true?).

Ian




:

It might be easier to do this just by adding an unbound option group
to
the
Header section of the form.

The group would have 3 buttons for Active, Inactive, and All
respectively,
so it looked like this:
[o] Active [ ] Inactive [ ] All

Set the group's AfterUpdate property to:
[Event Procedure]
Click the Build button (...) beside it.
Access opens the code window.
Set up the code like the example below:

Private Sub grpFilterActive_AfterUpdate()
If Me.Dirty Then Me.Dirty = False
Select Case Me.grpFilterActive.Value
Case 1
Me.Filter = "Inactive = False"
Me.FilterOn = True
Case 2
Me.Filter = "Inactive = True"
Me.FilterOn = True
Case Else
Me.FilterOn = False
End Select
End Sub

Additional hints
===========
1. Set the Default Value of the group to 1, so it defaults to active
clients.

2. Add this line to the form's On Open event procedure so it opens
filtered:
Call grpFilterActive_AfterUpdate

--
Allen Browne - Microsoft MVP. Perth, Western Australia

Reply to group, rather than allenbrowne at mvps dot org.

I have a main form [frm_main] that is based on the table with all
of
the
basic client data. Needless to say, I have built the entire db
around
this.
Anyway, all clients can be either active or inactive. This main
form
has
a
checkbox for active/inactive. I'd like to make a small subform in
the
swithboard with a yes/no box to show active (yes/no) and inactive
(yes/no)
clients.

I could do it with a query (an redirecting all form controls to
the
query
rather than the main table) but that seems like a hell of a lot of
work.
Is
there anyway to simply filter the forms based on the vaules of the
subform
in
the swithboard? the subfrom would be called LU_ShowActive with 2
fields;
value (active/inactive) and status (yes/no checkbox).

Hope this is possible. Thanks. Ian.
 
G

Guest

The name of the option button is grpfilteractive. I compiled and debugged
and here is the code. It is not giving any errors now but does nothing.
Even added a requery but I'm still seeing the forms with active set to false
when the grpfilteractive is set to false.

Private Sub grpFilterActive_AfterUpdate()
If Me.Dirty Then Me.Dirty = False
If Me.grpFilterActive = True Then
Me.Filter = "Active = False"
Me.FilterOn = False
If Me.grpFilterActive = False Then
Me.Filter = "Active = False"
Me.FilterOn = True
End If
End If
DoCmd.Requery (Frm_main)
End Sub


Allen Browne said:
Is the name of the option group [View inactives], or is it grpfilteractive?

Does the code compile? (Compile on Debug menu, in code window.)

What error message do you get?

--
Allen Browne - Microsoft MVP. Perth, Western Australia

Reply to group, rather than allenbrowne at mvps dot org.

Ian said:
I tried this code but it just didn't work (although I think I like the
logic). The option groups is "View Inactives" which is called
grpfilteractive
Private Sub grpFilterActive_AfterUpdate()
If Me.Dirty Then Me.Dirty = False
If Me.grpFilterActive = True Then
Me.Filter = "Active = False"
Me.FilterOn = False
If Me.grpFilterActive = False Then
Me.Filter = "Active = False"
Me.FilterOn = True
End Select


End Sub

Ian said:
not sure what i'm doing wrong but it's not doing anything:
the View Inactive option box is called grpFilterActive
The checkbox in the main form is called active
I put this code in the grpfilteractive after_update() field

Private Sub grpFilterActive_AfterUpdate()
If Me.Dirty Then Me.Dirty = False
Select Case Me.grpFilterActive.Value
Case 1
Me.Filter = "active = False"
Me.FilterOn = True
Case 2
Me.Filter = "active = True"
Me.FilterOn = True
Case Else
Me.FilterOn = False
End Select

End Sub
And the code in the main forms on open event field.

If the option group is on no filter should be applied, if the option
group
is off it should filter only the forms with active set to true??

thx.


:

If you name your option group "grpFilterActive", and your yes/no field
is
named "Inactive", you can use the code as it is.

If your names are different, change each time those names occur in the
code.
And add square brackets around the names if they contain spaces, e.g.:
Select Case Me.[view inactives].Value

--
Allen Browne - Microsoft MVP. Perth, Western Australia

Reply to group, rather than allenbrowne at mvps dot org.

Thanks again Allen. I put one option group button in the header
called
labelled "view inactives" (Option80). Sorry but I didn't understand
how
to
apply the code exactly What do I do though to define the grpFilter
(e.g.
when grpFilture is on only show the records in [main] where [active]
=
true?).

Ian




:

It might be easier to do this just by adding an unbound option group
to
the
Header section of the form.

The group would have 3 buttons for Active, Inactive, and All
respectively,
so it looked like this:
[o] Active [ ] Inactive [ ] All

Set the group's AfterUpdate property to:
[Event Procedure]
Click the Build button (...) beside it.
Access opens the code window.
Set up the code like the example below:

Private Sub grpFilterActive_AfterUpdate()
If Me.Dirty Then Me.Dirty = False
Select Case Me.grpFilterActive.Value
Case 1
Me.Filter = "Inactive = False"
Me.FilterOn = True
Case 2
Me.Filter = "Inactive = True"
Me.FilterOn = True
Case Else
Me.FilterOn = False
End Select
End Sub

Additional hints
===========
1. Set the Default Value of the group to 1, so it defaults to active
clients.

2. Add this line to the form's On Open event procedure so it opens
filtered:
Call grpFilterActive_AfterUpdate

--
Allen Browne - Microsoft MVP. Perth, Western Australia

Reply to group, rather than allenbrowne at mvps dot org.

I have a main form [frm_main] that is based on the table with all
of
the
basic client data. Needless to say, I have built the entire db
around
this.
Anyway, all clients can be either active or inactive. This main
form
has
a
checkbox for active/inactive. I'd like to make a small subform in
the
swithboard with a yes/no box to show active (yes/no) and inactive
(yes/no)
clients.

I could do it with a query (an redirecting all form controls to
the
query
rather than the main table) but that seems like a hell of a lot of
work.
Is
there anyway to simply filter the forms based on the vaules of the
subform
in
the swithboard? the subfrom would be called LU_ShowActive with 2
fields;
value (active/inactive) and status (yes/no checkbox).

Hope this is possible. Thanks. Ian.
 
A

Allen Browne

You used the values True and False for the option group?
Unless you set the OptionValue of your buttons to -1 and 0, that won't work.

Usually the first button is 1 and the 2nd is 2.
Try:
If Me.grpFilterActive = 1 Then
etc.

--
Allen Browne - Microsoft MVP. Perth, Western Australia

Reply to group, rather than allenbrowne at mvps dot org.

Ian said:
The name of the option button is grpfilteractive. I compiled and debugged
and here is the code. It is not giving any errors now but does nothing.
Even added a requery but I'm still seeing the forms with active set to
false
when the grpfilteractive is set to false.

Private Sub grpFilterActive_AfterUpdate()
If Me.Dirty Then Me.Dirty = False
If Me.grpFilterActive = True Then
Me.Filter = "Active = False"
Me.FilterOn = False
If Me.grpFilterActive = False Then
Me.Filter = "Active = False"
Me.FilterOn = True
End If
End If
DoCmd.Requery (Frm_main)
End Sub


Allen Browne said:
Is the name of the option group [View inactives], or is it
grpfilteractive?

Does the code compile? (Compile on Debug menu, in code window.)

What error message do you get?

Ian said:
I tried this code but it just didn't work (although I think I like the
logic). The option groups is "View Inactives" which is called
grpfilteractive
Private Sub grpFilterActive_AfterUpdate()
If Me.Dirty Then Me.Dirty = False
If Me.grpFilterActive = True Then
Me.Filter = "Active = False"
Me.FilterOn = False
If Me.grpFilterActive = False Then
Me.Filter = "Active = False"
Me.FilterOn = True
End Select


End Sub

:

not sure what i'm doing wrong but it's not doing anything:
the View Inactive option box is called grpFilterActive
The checkbox in the main form is called active
I put this code in the grpfilteractive after_update() field

Private Sub grpFilterActive_AfterUpdate()
If Me.Dirty Then Me.Dirty = False
Select Case Me.grpFilterActive.Value
Case 1
Me.Filter = "active = False"
Me.FilterOn = True
Case 2
Me.Filter = "active = True"
Me.FilterOn = True
Case Else
Me.FilterOn = False
End Select

End Sub
And the code in the main forms on open event field.

If the option group is on no filter should be applied, if the option
group
is off it should filter only the forms with active set to true??

thx.


:

If you name your option group "grpFilterActive", and your yes/no
field
is
named "Inactive", you can use the code as it is.

If your names are different, change each time those names occur in
the
code.
And add square brackets around the names if they contain spaces,
e.g.:
Select Case Me.[view inactives].Value

--
Allen Browne - Microsoft MVP. Perth, Western Australia

Reply to group, rather than allenbrowne at mvps dot org.

Thanks again Allen. I put one option group button in the header
called
labelled "view inactives" (Option80). Sorry but I didn't
understand
how
to
apply the code exactly What do I do though to define the
grpFilter
(e.g.
when grpFilture is on only show the records in [main] where
[active]
=
true?).

Ian




:

It might be easier to do this just by adding an unbound option
group
to
the
Header section of the form.

The group would have 3 buttons for Active, Inactive, and All
respectively,
so it looked like this:
[o] Active [ ] Inactive [ ] All

Set the group's AfterUpdate property to:
[Event Procedure]
Click the Build button (...) beside it.
Access opens the code window.
Set up the code like the example below:

Private Sub grpFilterActive_AfterUpdate()
If Me.Dirty Then Me.Dirty = False
Select Case Me.grpFilterActive.Value
Case 1
Me.Filter = "Inactive = False"
Me.FilterOn = True
Case 2
Me.Filter = "Inactive = True"
Me.FilterOn = True
Case Else
Me.FilterOn = False
End Select
End Sub

Additional hints
===========
1. Set the Default Value of the group to 1, so it defaults to
active
clients.

2. Add this line to the form's On Open event procedure so it
opens
filtered:
Call grpFilterActive_AfterUpdate

--
Allen Browne - Microsoft MVP. Perth, Western Australia

Reply to group, rather than allenbrowne at mvps dot org.

I have a main form [frm_main] that is based on the table with
all
of
the
basic client data. Needless to say, I have built the entire
db
around
this.
Anyway, all clients can be either active or inactive. This
main
form
has
a
checkbox for active/inactive. I'd like to make a small subform
in
the
swithboard with a yes/no box to show active (yes/no) and
inactive
(yes/no)
clients.

I could do it with a query (an redirecting all form controls to
the
query
rather than the main table) but that seems like a hell of a lot
of
work.
Is
there anyway to simply filter the forms based on the vaules of
the
subform
in
the swithboard? the subfrom would be called LU_ShowActive with
2
fields;
value (active/inactive) and status (yes/no checkbox).

Hope this is possible. Thanks. Ian.
 
G

Guest

couldn't get it to work again allen. So I just created an action button that
uses the applyfiter macro to the underlying table. I think it had something
to do with the Active checkbox value because I couldn't get it to filter even
with a simple macro. Anyway -- thanks for all the help. A two day thread is
a bit much. Thanks. Ian.


Allen Browne said:
You used the values True and False for the option group?
Unless you set the OptionValue of your buttons to -1 and 0, that won't work.

Usually the first button is 1 and the 2nd is 2.
Try:
If Me.grpFilterActive = 1 Then
etc.

--
Allen Browne - Microsoft MVP. Perth, Western Australia

Reply to group, rather than allenbrowne at mvps dot org.

Ian said:
The name of the option button is grpfilteractive. I compiled and debugged
and here is the code. It is not giving any errors now but does nothing.
Even added a requery but I'm still seeing the forms with active set to
false
when the grpfilteractive is set to false.

Private Sub grpFilterActive_AfterUpdate()
If Me.Dirty Then Me.Dirty = False
If Me.grpFilterActive = True Then
Me.Filter = "Active = False"
Me.FilterOn = False
If Me.grpFilterActive = False Then
Me.Filter = "Active = False"
Me.FilterOn = True
End If
End If
DoCmd.Requery (Frm_main)
End Sub


Allen Browne said:
Is the name of the option group [View inactives], or is it
grpfilteractive?

Does the code compile? (Compile on Debug menu, in code window.)

What error message do you get?

I tried this code but it just didn't work (although I think I like the
logic). The option groups is "View Inactives" which is called
grpfilteractive
Private Sub grpFilterActive_AfterUpdate()
If Me.Dirty Then Me.Dirty = False
If Me.grpFilterActive = True Then
Me.Filter = "Active = False"
Me.FilterOn = False
If Me.grpFilterActive = False Then
Me.Filter = "Active = False"
Me.FilterOn = True
End Select


End Sub

:

not sure what i'm doing wrong but it's not doing anything:
the View Inactive option box is called grpFilterActive
The checkbox in the main form is called active
I put this code in the grpfilteractive after_update() field

Private Sub grpFilterActive_AfterUpdate()
If Me.Dirty Then Me.Dirty = False
Select Case Me.grpFilterActive.Value
Case 1
Me.Filter = "active = False"
Me.FilterOn = True
Case 2
Me.Filter = "active = True"
Me.FilterOn = True
Case Else
Me.FilterOn = False
End Select

End Sub
And the code in the main forms on open event field.

If the option group is on no filter should be applied, if the option
group
is off it should filter only the forms with active set to true??

thx.


:

If you name your option group "grpFilterActive", and your yes/no
field
is
named "Inactive", you can use the code as it is.

If your names are different, change each time those names occur in
the
code.
And add square brackets around the names if they contain spaces,
e.g.:
Select Case Me.[view inactives].Value

--
Allen Browne - Microsoft MVP. Perth, Western Australia

Reply to group, rather than allenbrowne at mvps dot org.

Thanks again Allen. I put one option group button in the header
called
labelled "view inactives" (Option80). Sorry but I didn't
understand
how
to
apply the code exactly What do I do though to define the
grpFilter
(e.g.
when grpFilture is on only show the records in [main] where
[active]
=
true?).

Ian




:

It might be easier to do this just by adding an unbound option
group
to
the
Header section of the form.

The group would have 3 buttons for Active, Inactive, and All
respectively,
so it looked like this:
[o] Active [ ] Inactive [ ] All

Set the group's AfterUpdate property to:
[Event Procedure]
Click the Build button (...) beside it.
Access opens the code window.
Set up the code like the example below:

Private Sub grpFilterActive_AfterUpdate()
If Me.Dirty Then Me.Dirty = False
Select Case Me.grpFilterActive.Value
Case 1
Me.Filter = "Inactive = False"
Me.FilterOn = True
Case 2
Me.Filter = "Inactive = True"
Me.FilterOn = True
Case Else
Me.FilterOn = False
End Select
End Sub

Additional hints
===========
1. Set the Default Value of the group to 1, so it defaults to
active
clients.

2. Add this line to the form's On Open event procedure so it
opens
filtered:
Call grpFilterActive_AfterUpdate

--
Allen Browne - Microsoft MVP. Perth, Western Australia

Reply to group, rather than allenbrowne at mvps dot org.

I have a main form [frm_main] that is based on the table with
all
of
the
basic client data. Needless to say, I have built the entire
db
around
this.
Anyway, all clients can be either active or inactive. This
main
form
has
a
checkbox for active/inactive. I'd like to make a small subform
in
the
swithboard with a yes/no box to show active (yes/no) and
inactive
(yes/no)
clients.

I could do it with a query (an redirecting all form controls to
the
query
rather than the main table) but that seems like a hell of a lot
of
work.
Is
there anyway to simply filter the forms based on the vaules of
the
subform
in
the swithboard? the subfrom would be called LU_ShowActive with
2
fields;
value (active/inactive) and status (yes/no checkbox).

Hope this is possible. Thanks. Ian.
 

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