Using Tab Controls to display form and determine filtering

B

Biomed

Access 2000, WIN 2000

I am creating a form for a vendor listing. I want to use tab controls to
set the filtering for each letter of the alphabet "A, B C,..Z" to list
vendors that begin with that particular letter.

Two questions:
1) Do I have to put the same subform on each page of the tab control or is
there a cleaner way?

2) How do I apply filtering to the subform to filter for all the vendors
starting with "A", "B", ..."Z". (Like a rolodex)The master form is called
"Main" and the subform is called "Vendor Listing" with its record source set
to the query "qryVendor".

Thanks for your expertise!
 
D

Dirk Goldgar

Biomed said:
Access 2000, WIN 2000

I am creating a form for a vendor listing. I want to use tab
controls to set the filtering for each letter of the alphabet "A, B
C,..Z" to list vendors that begin with that particular letter.

Two questions:
1) Do I have to put the same subform on each page of the tab control
or is there a cleaner way?

2) How do I apply filtering to the subform to filter for all the
vendors starting with "A", "B", ..."Z". (Like a rolodex)The master
form is called "Main" and the subform is called "Vendor Listing" with
its record source set to the query "qryVendor".

Thanks for your expertise!

So your idea is to have a tab control with 26 tabs, captioned A to Z?
And then, the subform will show the records for whichever tab is
currently selected?

I haven't set up such an arrangement, but I believe you could put a
single subform control on the form *behind* the tab control -- then it
will show through the tab pages. You could use the tab control's Change
event to apply a filter to the subform, like this:

'----- start of example code -----
Private Sub TabCtl0_Change()

Dim strFilter As String

With Me.TabCtl0
strFilter = "LastName Like """ & _
.Pages(.Value).Caption & _
"*"""
End With

With Me.sfVendors.Form
.Filter = strFilter
.FilterOn = True
End With

End Sub

'----- end of example code -----

You'll also want to force the filtering to be applied when the form is
first opened, so put a line of code in the form's Load event, like this:

'----- start of code -----
Private Sub Form_Load()

Call TabCtl0_Change

End Sub
'----- end of 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