Filter Form but Label Click (1 Viewer)

flavioso

Registered User.
Local time
Today, 14:42
Joined
Jan 21, 2008
Messages
16
Hello:

Please see the image below. What I am trying to achieve is when the user clicks on a letter (26 labels), the subform is filtered to the field fldLETTER according to the label. I have about 19,000 records and each has a 1 letter code for sorting. So when they click on label1 (A), it would filter the subform to only records that have a value of A in the the field fldLETTER.

One thought was to have a hidden textbox when the button is clicked, the text box is updated with the text value, as I have here in this code:

Code:
Private Sub Label1_Click()
txtLETTER.Value = "A"
End Sub

My problem is trying to come up with a way to either filter the subform based on the change in the hidden text box (txtLETTER), or just when the button is clicked.

Does anyone have any suggestions? I appreciate any help in advance.

 

John Big Booty

AWF VIP
Local time
Tomorrow, 07:42
Joined
Aug 29, 2005
Messages
8,263
In your Label's OnClick event put the following;

Code:
Me.frmSubform.Form.Filter = "[fldLETTER]=" & Me.LabelName.Caption
Me.frmSubform.Form.FilterOn = True

To remove the filter once you are done use;

Code:
Me.frmSubform.Form.FilterOn = False

Replace frmSubform with the SourceObject name of your subform.
Replace LabelName with the name of your Label
 

Users who are viewing this thread

Top Bottom