Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Alphabet buttons remove filtering...why? 1

Status
Not open for further replies.

AccipiterQ

Programmer
May 25, 2005
27
US
I have a switchboard form in my database with several buttons on it. Each button opens the main form for the database and displays only a certain set of records...it's using a VBA filter. Now along the bottom of the main form is a set of alphabetical buttons, basically it's to show only those who have a last name of 'a, b, c' etc. you get the point. However when I hit the alphabetical button, it removes the filter that the switchboard form applies...is there any way around htis...so that the filter is still applied, and when the alphabet button is hit, you only see those with a last name that starts with say, 'A' within the filtered selection? The alphabet buttons are linked to a macro...and here's an example of the switchboard button's VBA:

Private Sub AFP_Button_Click()
On Error GoTo Err_AFP_Button_Click

Dim stDocName As String

stDocName = "Master List: Businesses"
DoCmd.OpenForm stDocName, , , "[From]='AFP'"


Exit_AFP_Button_Click:
Exit Sub

Err_AFP_Button_Click:
MsgBox Err.Description
Resume Exit_AFP_Button_Click

End Sub

the "[From]='AFP'" is what filters out the other records so that only entries with 'AFP' in the From field show up.
 
there's 2 options

1) combine both the switchboard filter and buttons filter into one single filter, which should then be applied to the form upon a button hit

2) apply the button filter only the the recordset of the opened form

I'm not 100% sure the 2nd method will work though...

--------------------
Procrastinate Now!
 
I don't suppose you'd know how to combined the two filters into one...I'm not exactly a pro with VBA
 
with the keywords AND + OR...

blah = value AND otherBlah = moveValue

--------------------
Procrastinate Now!
 
hmm wouldn't I have to program it for each letter of the alphabet then along with each button on my switchboard form...i.e. a button for clients from a Turkey Drive we had that began with the letter A, then another button for letter B, etc. ?
 
I basically just don't want the filter applied by the switchboard to be removed when I hit one of the alphabetical buttons after the form opens.
 
How are ya AccipiterQ . . .

The easiest thing I see you can do, is [blue]make a query for each filter button[/blue] on your switchboard and [blue]apply the approriate query to the RecordSource of the Main Form[/blue].
Code:
[blue]   DoCmd.OpenForm "MainFormName"
   Forms!MainFormName.RecordSource = "QueryName"[/blue]
In this way your alphabet filters should work as is ([blue]you'll be filtering the query[/blue], instead of overwriting the previous filter set by the switchboard.

When you try this, don't forget to save the Main Form with an empty RecordSource 1st! (just to remove interaction).

Calvin.gif
See Ya! . . . . . .
 
It appears successful! Thank you very much, I'm going to tinker with it and see if it continues to work appropriately!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top