Enable field during filter only

E

Emma Aumack

Hi all,

I have a couple of fields on a form that are disabled. I need to be able to
allow the user to filter on these fields when they use Access "Filter by
Form". However, when select "filter by form" they remain disabled.

I have tried putting this code in the "On Current" of the form but it looks
like I'm missing the boat here. Little help please?

If Me.FilterOn = True Then

Me.Job_ID.Enabled = True
Me.Date_Entered.Enabled = True

Else

Me.Job_ID.Enabled = False
Me.Date_Entered.Enabled = False

End If
 
B

bad man

Hello, Emma.

I have a question. Would you please allow me to have permission to get
inside your pants?
 
E

Emma Aumack

Is there someone out there monitoring this stuff? I have to say, this was a
first for me in this this newsgroup.
 
G

Graham Mandeno

Hi Emma

I'm sorry you have experienced abuse such as this in these newsgroups. It
seems you have not been the only one. Let's hope "bad man" is dealt with
quickly and effectively :)

You can use the form's Filter event to do what you want. I don't have any
tested sample code because I never use filter by form, but the online help
states:

You can use the Filter event to:
[snip]
Prevent certain controls on the form from appearing or being used in the
Filter By Form or Server Filter By Form window. If you hide or disable a
control in the Filter macro or event procedure, the control is hidden or
disabled in the Filter By Form or Server Filter By Form window, and can't be
used to set filter criteria. You can then use the ApplyFilter event to show
or enable this control after the filter is applied, or when the filter is
removed from the form.

I imagine the code you need will be something like this:

Private Sub Form_Filter(Cancel As Integer, FilterType As Integer)
If FilterType = acFilterByForm Then
Me.Job_ID.Enabled = True
Me.Date_Entered.Enabled = True
End If
End Sub
 
E

Emma Aumack

Thank you Graham, tht was exactly what I needed.
--
www.bardpv.com
Tempe, Arizona


Graham Mandeno said:
Hi Emma

I'm sorry you have experienced abuse such as this in these newsgroups. It
seems you have not been the only one. Let's hope "bad man" is dealt with
quickly and effectively :)

You can use the form's Filter event to do what you want. I don't have any
tested sample code because I never use filter by form, but the online help
states:

You can use the Filter event to:
[snip]
Prevent certain controls on the form from appearing or being used in the
Filter By Form or Server Filter By Form window. If you hide or disable a
control in the Filter macro or event procedure, the control is hidden or
disabled in the Filter By Form or Server Filter By Form window, and can't be
used to set filter criteria. You can then use the ApplyFilter event to show
or enable this control after the filter is applied, or when the filter is
removed from the form.

I imagine the code you need will be something like this:

Private Sub Form_Filter(Cancel As Integer, FilterType As Integer)
If FilterType = acFilterByForm Then
Me.Job_ID.Enabled = True
Me.Date_Entered.Enabled = True
End If
End Sub
--
Good Luck!

Graham Mandeno [Access MVP]
Auckland, New Zealand


Emma Aumack said:
Hi all,

I have a couple of fields on a form that are disabled. I need to be able
to
allow the user to filter on these fields when they use Access "Filter by
Form". However, when select "filter by form" they remain disabled.

I have tried putting this code in the "On Current" of the form but it
looks
like I'm missing the boat here. Little help please?

If Me.FilterOn = True Then

Me.Job_ID.Enabled = True
Me.Date_Entered.Enabled = True

Else

Me.Job_ID.Enabled = False
Me.Date_Entered.Enabled = False

End If

--
Emma Aumack
Associate Sales Analyst
www.bardpv.com
Tempe, Arizona
 
Top