T
Ted
Hi all,
i'm trying to use the For Each...Next statement. the problem is the code is
in one
form and i'm looking at another. i can run the code if i hardcode the form
name but
the form will change depending on what the user chooses as a State on the
first form.
for example:
For Each ctrl In Forms![frmNJForms].Controls
If TypeOf ctrl Is CheckBox Then
If ctrl.Value = True Then
varFormName = Mid(ctrl.Name, 4, 2) & " " & Mid(ctrl.Name, 6, 4)
End If
objWord.selection.typetext varFormName
End If
Next
i don't want to hardcode Forms![frmNJForms] because it might be
Forms![frmMNForms] or Forms![frmNYForms] etc...
i tried:
Dim varStateForm as object
varStateForm = "Forms![frm" & txtInsuredState & "Forms]"
For Each ctrl In varStateForm.Controls
..
..
..
but i get "Object variable or With block variable not set"
How can i set the the frm&txtInsuredState&Forms as the object?
Thanks in Advance
Ted
i'm trying to use the For Each...Next statement. the problem is the code is
in one
form and i'm looking at another. i can run the code if i hardcode the form
name but
the form will change depending on what the user chooses as a State on the
first form.
for example:
For Each ctrl In Forms![frmNJForms].Controls
If TypeOf ctrl Is CheckBox Then
If ctrl.Value = True Then
varFormName = Mid(ctrl.Name, 4, 2) & " " & Mid(ctrl.Name, 6, 4)
End If
objWord.selection.typetext varFormName
End If
Next
i don't want to hardcode Forms![frmNJForms] because it might be
Forms![frmMNForms] or Forms![frmNYForms] etc...
i tried:
Dim varStateForm as object
varStateForm = "Forms![frm" & txtInsuredState & "Forms]"
For Each ctrl In varStateForm.Controls
..
..
..
but i get "Object variable or With block variable not set"
How can i set the the frm&txtInsuredState&Forms as the object?
Thanks in Advance
Ted