Friday
Registered User.
- Local time
- Today, 07:55
- Joined
- Apr 11, 2003
- Messages
- 542
I have a form - frmBridge1. It has a subform sqlBridge1_subform. In the first field on the subform, I am using the gotfocus event to do some things. I want to use 4 different subforms on this main form, but the function I originally built was for a single subform. I want to reference the subform dynamically and build a pointer to the current control name.
Here is part of the code:
Dim Qtext As String
Dim rstSubForm As Form
Dim rstMainForm As Form
Set rstSubForm = Screen.ActiveControl.Parent 'this gives me the current subform name
Set rstMainForm = Screen.ActiveForm 'this returns the main form name
'then I would have a line like:
Qtext = Forms!rstMainForm.rstSubForm.Form.ActiveControl.Name 'this errors out - "Microsoft Office Access can't find the form 'rstMainForm' referred to in a macro expression or Visual Basic code"
'Currently I am using this code, which works great for the existing subform:
Qtext = Forms!frmBridge1.sqlBridge1_subform.Form.ActiveControl.Name
I am sure this is clear as mud. Can anyone point me in the right direction?
Here is part of the code:
Dim Qtext As String
Dim rstSubForm As Form
Dim rstMainForm As Form
Set rstSubForm = Screen.ActiveControl.Parent 'this gives me the current subform name
Set rstMainForm = Screen.ActiveForm 'this returns the main form name
'then I would have a line like:
Qtext = Forms!rstMainForm.rstSubForm.Form.ActiveControl.Name 'this errors out - "Microsoft Office Access can't find the form 'rstMainForm' referred to in a macro expression or Visual Basic code"
'Currently I am using this code, which works great for the existing subform:
Qtext = Forms!frmBridge1.sqlBridge1_subform.Form.ActiveControl.Name
I am sure this is clear as mud. Can anyone point me in the right direction?