Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I'm in a hurry, so don't have time to name all your variables back to the
beginning. Take a look at this though, I think it will give some help. Don't see a need for global variables. TabIndex starts at 0, not 1, which I realized easily since my forms only had one control each. Anyways, hope this gives some help: Option Explicit Sub CreateOrderItemAvail() Dim ctlFormControl, ctlFormControl_2 As MSForms.Control Dim i As Long, j As Long Dim strCtrltext As String For i = 0 To 22 Step 4 For Each ctlFormControl In UserForm1.Controls If ctlFormControl.TabIndex = i Then strCtrltext = ctlFormControl.Caption For j = 0 To 35 Step 6 For Each ctlFormControl_2 In UserForm2.Controls If ctlFormControl_2.TabIndex = j Then ctlFormControl_2.Caption = strCtrltext End If Next ctlFormControl_2 Next j End If Next ctlFormControl Next i UserForm1.Show UserForm2.Show MsgBox "Is this what you want?" Unload UserForm1 Unload UserForm2 End Sub Doug wrote in message oups.com... Thanks Doug & Jim! That makes a lot of sense and I think that problem is solved. The big problem that I have now is that control objects, i.e. ctlFormControl & ctlFormControl2, do not support the text or caption proporties and I need to be able to get the text or cation out of the selected control..........I can't see a way to do this. For example: in this procedure I am looping through the controls on form frmQueryResult, getting the tabindex for a given control on the form, then finding the corresponding control on form frmCreateOrder. I want to set the control value in frmCreateOrder to the value in the frmQueryResult control. Doesn't work........... 'fill in item availability controls on create order form Sub CreateOrderItemAvail() For i = 6 To 22 Step 4 For Each ctlFormControl In frmQueryResult.Controls If ctlFormControl.TabIndex = i Then strCtrltext = ctlFormControl.Caption For j = 11 To 35 Step 6 For Each ctlFormControl_2 In frmCreateOrder.Controls If ctlFormControl_2.TabIndex = j Then ctlFormControl_2.Caption = strCtrltext End If Next ctlFormControl_2 Next j End If Next ctlFormControl Next i End Sub Brian |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Type mismatch using rnge as Range with Type 8 Input Box | Excel Programming | |||
Help: Compile error: type mismatch: array or user defined type expected | Excel Programming | |||
type mismatch--how to fix | Excel Discussion (Misc queries) | |||
13 type mismatch help | Excel Programming | |||
Type mismatch | Excel Programming |