B
BruceM
I have a form/subform based on related tables (one-to-many). The main form
has a tab control. I would like to filter the subform record source based
on the selected tab. Since the tabs themselves don't have useful Click
events, I have used the Got Focus event of the first control in the tab
order to set the subform record source. There is a function to extract the
tab's caption:
Public Function TabCapt(frm As Form) As String
Dim lngIndex As Long ' PageIndex property
lngIndex = frm.tabCAR.Value
TabCapt = frm.tabCAR.Pages.Item(lngIndex).Caption 'Caption of current tab
End Function
Then there is a function that works with TabCapt:
Public Function EvSQL()
Dim strEvSQL As String
strEvSQL = conEvSQL & TabCapt(Form) & """"
Forms!frmCAR!fsubEvLink.Form.RecordSource = strEvSQL
End Function
Finally, in the Got Focus property for the first control in the tab order:
=EvSQL()
TabCapt and EvSQL are two different functions because sometimes I need the
caption by itself. Anyhow, the system works, but it seems rather
roundabout. In particular, am I overlooking something that would cause
EvSQL to run when the tab is clicked (or when the current tab changes)
rather than by using the GotFocus event?
has a tab control. I would like to filter the subform record source based
on the selected tab. Since the tabs themselves don't have useful Click
events, I have used the Got Focus event of the first control in the tab
order to set the subform record source. There is a function to extract the
tab's caption:
Public Function TabCapt(frm As Form) As String
Dim lngIndex As Long ' PageIndex property
lngIndex = frm.tabCAR.Value
TabCapt = frm.tabCAR.Pages.Item(lngIndex).Caption 'Caption of current tab
End Function
Then there is a function that works with TabCapt:
Public Function EvSQL()
Dim strEvSQL As String
strEvSQL = conEvSQL & TabCapt(Form) & """"
Forms!frmCAR!fsubEvLink.Form.RecordSource = strEvSQL
End Function
Finally, in the Got Focus property for the first control in the tab order:
=EvSQL()
TabCapt and EvSQL are two different functions because sometimes I need the
caption by itself. Anyhow, the system works, but it seems rather
roundabout. In particular, am I overlooking something that would cause
EvSQL to run when the tab is clicked (or when the current tab changes)
rather than by using the GotFocus event?