Filter in Command Button

G

Guest

I have a form (frmMain) that is based upon a query (qryDataParcel). In this
form I have a command button that brings up a pop up menu with a variety of
text, drop down menus and other command buttons. Of these other command
buttons, two of which are to be used to filter the field named [Parcel].
ON = [Parcel]<> 999
OFF = no filter.
I can’t seem to get the code behinds these command buttons to work. This is
what I am currently trying to get working.

Private Sub Command2_Click()
Filter = "[frmMain].[Parcel] <> 999"
FilterOn = True
End Sub

Any thoughts on what I am doing wrong and how to write the Filter Off code?
 
P

PC Datasheet

To turn on:
Forms!FrmMain.Filter = "[Parcel]<>999"
Forms!FrmMain.FilterOn = True

To turn off:
Forms!FrmMain.FilterOn = False

--
PC Datasheet
Your Resource For Help With Access, Excel And Word Applications
(e-mail address removed)
www.pcdatasheet.com



briank said:
I have a form (frmMain) that is based upon a query (qryDataParcel). In this
form I have a command button that brings up a pop up menu with a variety of
text, drop down menus and other command buttons. Of these other command
buttons, two of which are to be used to filter the field named [Parcel].
ON = [Parcel]<> 999
OFF = no filter.
I can't seem to get the code behinds these command buttons to work. This is
what I am currently trying to get working.

Private Sub Command2_Click()
Filter = "[frmMain].[Parcel] <> 999"
FilterOn = True
End Sub

Any thoughts on what I am doing wrong and how to write the Filter Off
code?
 
G

Guest

Still having a problem with a code that is probably a no brainer. I have
inserted the following:

Private Sub Command2_Click()
Forms![frmMain].Filter = "[Parcel] <> 999"
Forms![frmMain].FilterOn = True
End Sub

When I click the command button I get a run time error and a message that
says, "You've canceled the previous operation". Any thoughts as to what am I
missing?


PC Datasheet said:
To turn on:
Forms!FrmMain.Filter = "[Parcel]<>999"
Forms!FrmMain.FilterOn = True

To turn off:
Forms!FrmMain.FilterOn = False

--
PC Datasheet
Your Resource For Help With Access, Excel And Word Applications
(e-mail address removed)
www.pcdatasheet.com



briank said:
I have a form (frmMain) that is based upon a query (qryDataParcel). In this
form I have a command button that brings up a pop up menu with a variety of
text, drop down menus and other command buttons. Of these other command
buttons, two of which are to be used to filter the field named [Parcel].
ON = [Parcel]<> 999
OFF = no filter.
I can't seem to get the code behinds these command buttons to work. This is
what I am currently trying to get working.

Private Sub Command2_Click()
Filter = "[frmMain].[Parcel] <> 999"
FilterOn = True
End Sub

Any thoughts on what I am doing wrong and how to write the Filter Off
code?
 
P

PC Datasheet

That message indicates another process is on hold when you click the button.
Look to see what else you are doing at the same time. You could also add the
following as the first line of your button's code which should negate the
error message:
On Error Resume Next

--
PC Datasheet
Your Resource For Help With Access, Excel And Word Applications
(e-mail address removed)
www.pcdatasheet.com


briank said:
Still having a problem with a code that is probably a no brainer. I have
inserted the following:

Private Sub Command2_Click()
Forms![frmMain].Filter = "[Parcel] <> 999"
Forms![frmMain].FilterOn = True
End Sub

When I click the command button I get a run time error and a message that
says, "You've canceled the previous operation". Any thoughts as to what am I
missing?


PC Datasheet said:
To turn on:
Forms!FrmMain.Filter = "[Parcel]<>999"
Forms!FrmMain.FilterOn = True

To turn off:
Forms!FrmMain.FilterOn = False

--
PC Datasheet
Your Resource For Help With Access, Excel And Word Applications
(e-mail address removed)
www.pcdatasheet.com



briank said:
I have a form (frmMain) that is based upon a query (qryDataParcel).
In
this
form I have a command button that brings up a pop up menu with a
variety
of
text, drop down menus and other command buttons. Of these other command
buttons, two of which are to be used to filter the field named [Parcel].
ON = [Parcel]<> 999
OFF = no filter.
I can't seem to get the code behinds these command buttons to work.
This
is
what I am currently trying to get working.

Private Sub Command2_Click()
Filter = "[frmMain].[Parcel] <> 999"
FilterOn = True
End Sub

Any thoughts on what I am doing wrong and how to write the Filter Off
code?
 
G

Guest

Yep, you were correct. I had another process on hold. BTW, the "On Error
Resume Next" worked great. TY.

PC Datasheet said:
That message indicates another process is on hold when you click the button.
Look to see what else you are doing at the same time. You could also add the
following as the first line of your button's code which should negate the
error message:
On Error Resume Next

--
PC Datasheet
Your Resource For Help With Access, Excel And Word Applications
(e-mail address removed)
www.pcdatasheet.com


briank said:
Still having a problem with a code that is probably a no brainer. I have
inserted the following:

Private Sub Command2_Click()
Forms![frmMain].Filter = "[Parcel] <> 999"
Forms![frmMain].FilterOn = True
End Sub

When I click the command button I get a run time error and a message that
says, "You've canceled the previous operation". Any thoughts as to what am I
missing?


PC Datasheet said:
To turn on:
Forms!FrmMain.Filter = "[Parcel]<>999"
Forms!FrmMain.FilterOn = True

To turn off:
Forms!FrmMain.FilterOn = False

--
PC Datasheet
Your Resource For Help With Access, Excel And Word Applications
(e-mail address removed)
www.pcdatasheet.com



I have a form (frmMain) that is based upon a query (qryDataParcel). In
this
form I have a command button that brings up a pop up menu with a variety
of
text, drop down menus and other command buttons. Of these other command
buttons, two of which are to be used to filter the field named [Parcel].
ON = [Parcel]<> 999
OFF = no filter.
I can't seem to get the code behinds these command buttons to work. This
is
what I am currently trying to get working.

Private Sub Command2_Click()
Filter = "[frmMain].[Parcel] <> 999"
FilterOn = True
End Sub

Any thoughts on what I am doing wrong and how to write the Filter Off
code?
 

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