K
Kirk Wilson
I want to programatically assign values to controls. I can do it
explicitly but am unable to do it by reference.
frmPreWash1 is the main form
frmDiagnostics is a tabed subform on frmPreWash1
DateOfVisit is a textbox on frmPreWash1
DateOfVisit is a control for a column in the underlaying table
tblDiagnostices
The user enters a date in the main form text box.
The Tabed subform has multiple tabs each relating to a different table.
Each subtable has a column for [DateOfVisit]
As the user enters data on each subform I want to capture the main form
textbox date for each subform control.
I can do this explicitly for each tabed subform with appropriate
identifiers using the following sample code;
Private Sub Form_Dirty(Cancel As Integer)
Forms![frmPreWash1]![frmDiagnostice].Form![DateOfVisit] =
Forms![frmPreWash1].Form![DateOfVisit]
End Sub
I created a public string variable strFormName and initialized it with
the onCurrent event of frmPreWash1 using strFormName = Form.Name
I then wrote the following code which doesn't work
Private Sub Form_Dirty(Cancel As Integer)
Dim strSubFormName As String
strSubFormName = Form.Name
Forms![strFormName]![strSubFormName].Form![DateOfVisit] =
Forms![strFormName].Form![DateOfVisit]
End Sub
I get a run time error cant find...
I set a break point and verified that each variable has the correct name.
I tried the following as an alternate. No Joy.
Forms(strFormName)(strSubFormName).Form![DateOfVisit] =
Forms(strFormName).Form![DateOfVisit]
1. How can I indirectly refer to forms, subforms & controls to acomplish
this?
2. Can I get the main form's name from the subform so as to not have to
use a public variable?
I'm pretty sure this is just a syntax issue but can't find a hint anywhere.
Thanks in advance.
explicitly but am unable to do it by reference.
frmPreWash1 is the main form
frmDiagnostics is a tabed subform on frmPreWash1
DateOfVisit is a textbox on frmPreWash1
DateOfVisit is a control for a column in the underlaying table
tblDiagnostices
The user enters a date in the main form text box.
The Tabed subform has multiple tabs each relating to a different table.
Each subtable has a column for [DateOfVisit]
As the user enters data on each subform I want to capture the main form
textbox date for each subform control.
I can do this explicitly for each tabed subform with appropriate
identifiers using the following sample code;
Private Sub Form_Dirty(Cancel As Integer)
Forms![frmPreWash1]![frmDiagnostice].Form![DateOfVisit] =
Forms![frmPreWash1].Form![DateOfVisit]
End Sub
I created a public string variable strFormName and initialized it with
the onCurrent event of frmPreWash1 using strFormName = Form.Name
I then wrote the following code which doesn't work
Private Sub Form_Dirty(Cancel As Integer)
Dim strSubFormName As String
strSubFormName = Form.Name
Forms![strFormName]![strSubFormName].Form![DateOfVisit] =
Forms![strFormName].Form![DateOfVisit]
End Sub
I get a run time error cant find...
I set a break point and verified that each variable has the correct name.
I tried the following as an alternate. No Joy.
Forms(strFormName)(strSubFormName).Form![DateOfVisit] =
Forms(strFormName).Form![DateOfVisit]
1. How can I indirectly refer to forms, subforms & controls to acomplish
this?
2. Can I get the main form's name from the subform so as to not have to
use a public variable?
I'm pretty sure this is just a syntax issue but can't find a hint anywhere.
Thanks in advance.