Subform, how do I populate only when clicking on tab

D

Denise

Please explain how to populate the record source of the subform when the user
clicks on the tab.
 
D

Damon Heron

Look for the tabCtl object, and in the change or click event, enter:

dim strsql as string
If [your tabCtl Name].value = [the tabnumber that holds your subform] Then
strsql = "SELECT * from [yourtable that is the source of the subform]"
' if there are Where conditions, add them to the sql string also

Me!yoursubfrmName.Form.RecordSource = strsql
Me!yoursubfrmName.Form.Requery
End If

Tabs are usually zero-based, so the first tab is 0, then 1, etc.

Damon
 
Top