S
smithb2
I am getting a runtime error of "Type Mismatch" and can not figure out
why:
I declare the following:
Public ctlFormControl, ctlFormControl_2 As Controls
These Control variables are then used in the following procedure which
fills in item controls on a form called "frmCreateOrder" by taking text
from "frmNewOrder." This is done by looping through the controls on
the given form, using the TabIndex of the controls on the form.
Sub CreateOrderItems()
For i = 4 To 12 Step 2
For Each ctlFormControl In frmNewOrder.Controls
If ctlFormControl.TabIndex = i Then
strCtrltext = ctlFormControl.Text
For j = 9 To 33 Step 6
TYPE MISMATCH OCCURS IN THE FOLLOWING BLOCK:
For Each ctlFormControl_2 In
frmCreateOrder.Controls
If ctlFormControl_2.TabIndex = i Then
ctlFormControl_2.Caption = strCtrltext
End If
Next ctlFormControl_2
Next j
End If
Next ctlFormControl
Next i
It appears that VBA is having a problem with ctlFormControl_2. The
puzzling thing is that ctlFormControl is declared the same way, used in
the same way, and works.
Any Suggestions as to what the problem is?
Thanks,
Brian
why:
I declare the following:
Public ctlFormControl, ctlFormControl_2 As Controls
These Control variables are then used in the following procedure which
fills in item controls on a form called "frmCreateOrder" by taking text
from "frmNewOrder." This is done by looping through the controls on
the given form, using the TabIndex of the controls on the form.
Sub CreateOrderItems()
For i = 4 To 12 Step 2
For Each ctlFormControl In frmNewOrder.Controls
If ctlFormControl.TabIndex = i Then
strCtrltext = ctlFormControl.Text
For j = 9 To 33 Step 6
TYPE MISMATCH OCCURS IN THE FOLLOWING BLOCK:
For Each ctlFormControl_2 In
frmCreateOrder.Controls
If ctlFormControl_2.TabIndex = i Then
ctlFormControl_2.Caption = strCtrltext
End If
Next ctlFormControl_2
Next j
End If
Next ctlFormControl
Next i
It appears that VBA is having a problem with ctlFormControl_2. The
puzzling thing is that ctlFormControl is declared the same way, used in
the same way, and works.
Any Suggestions as to what the problem is?
Thanks,
Brian