Shelley said:
Does anyone remember seeing a sample form with a button
for each letter of the alphabet that would filter the
form, i.e. if you click on 'A', you would only see
customers whose name starts with 'A'? I have been
searching for it to copy and paste the code (rather than
having to re-write it myself) but can't find it.
Thanks in advance,
Shelley
The control is an option group with 27 buttons.
A thru Z and All.
The option values are 1 thru 27.
Private Sub FilterButtons_Click()
Select Case Forms![Contract Master]![FilterButtons]
Case 1
Forms![Contract Master].RecordSource = "Select *
From [Employer Contract Query] Where [EMID] Like " & "'" &
"A*" & "'"
Case 2
Forms![Contract Master].RecordSource = "Select *
From [Employer Contract Query] Where [EMID] Like " & "'" &
"B*" & "'"
Case 3
Forms![Contract Master].RecordSource = "Select *
From [Employer Contract Query] Where [EMID] Like " & "'" &
"C*" & "'"
Case 4
Forms![Contract Master].RecordSource = "Select *
From [Employer Contract Query] Where [EMID] Like " & "'" &
"D*" & "'"
Case 5
Forms![Contract Master].RecordSource = "Select *
From [Employer Contract Query] Where [EMID] Like " & "'" &
"E*" & "'"
Case 6
Forms![Contract Master].RecordSource = "Select *
From [Employer Contract Query] Where [EMID] Like " & "'" &
"F*" & "'"
Case 7
Forms![Contract Master].RecordSource = "Select *
From [Employer Contract Query] Where [EMID] Like " & "'" &
"G*" & "'"
Case 8
Forms![Contract Master].RecordSource = "Select *
From [Employer Contract Query] Where [EMID] Like " & "'" &
"H*" & "'"
Case 9
Forms![Contract Master].RecordSource = "Select *
From [Employer Contract Query] Where [EMID] Like " & "'" &
"I*" & "'"
Case 10
Forms![Contract Master].RecordSource = "Select *
From [Employer Contract Query] Where [EMID] Like " & "'" &
"J*" & "'"
Case 11
Forms![Contract Master].RecordSource = "Select *
From [Employer Contract Query] Where [EMID] Like " & "'" &
"K*" & "'"
Case 12
Forms![Contract Master].RecordSource = "Select *
From [Employer Contract Query] Where [EMID] Like " & "'" &
"L*" & "'"
Case 13
Forms![Contract Master].RecordSource = "Select *
From [Employer Contract Query] Where [EMID] Like " & "'" &
"M*" & "'"
Case 14
Forms![Contract Master].RecordSource = "Select *
From [Employer Contract Query] Where [EMID] Like " & "'" &
"N*" & "'"
Case 15
Forms![Contract Master].RecordSource = "Select *
From [Employer Contract Query] Where [EMID] Like " & "'" &
"O*" & "'"
Case 16
Forms![Contract Master].RecordSource = "Select *
From [Employer Contract Query] Where [EMID] Like " & "'" &
"P*" & "'"
Case 17
Forms![Contract Master].RecordSource = "Select *
From [Employer Contract Query] Where [EMID] Like " & "'" &
"Q*" & "'"
Case 18
Forms![Contract Master].RecordSource = "Select *
From [Employer Contract Query] Where [EMID] Like " & "'" &
"R*" & "'"
Case 19
Forms![Contract Master].RecordSource = "Select *
From [Employer Contract Query] Where [EMID] Like " & "'" &
"S*" & "'"
Case 20
Forms![Contract Master].RecordSource = "Select *
From [Employer Contract Query] Where [EMID] Like " & "'" &
"T*" & "'"
Case 21
Forms![Contract Master].RecordSource = "Select *
From [Employer Contract Query] Where [EMID] Like " & "'" &
"U*" & "'"
Case 22
Forms![Contract Master].RecordSource = "Select *
From [Employer Contract Query] Where [EMID] Like " & "'" &
"V*" & "'"
Case 23
Forms![Contract Master].RecordSource = "Select *
From [Employer Contract Query] Where [EMID] Like " & "'" &
"W*" & "'"
Case 24
Forms![Contract Master].RecordSource = "Select *
From [Employer Contract Query] Where [EMID] Like " & "'" &
"X*" & "'"
Case 25
Forms![Contract Master].RecordSource = "Select *
From [Employer Contract Query] Where [EMID] Like " & "'" &
"Y*" & "'"
Case 26
Forms![Contract Master].RecordSource = "Select *
From [Employer Contract Query] Where [EMID] Like " & "'" &
"Z*" & "'"
Case 27
Forms![Contract Master].RecordSource = "Select *
From [Employer Contract Query] Where [EMID] Like " & "'" &
"*" & "'"
End Select
Forms![Contract Master].Requery
Forms![Contract Master].Refresh
HTH
Ron
--
Ronald W. Roberts
Roberts Communication
(e-mail address removed)
To reply remove "_at_robcom_dot_com"