you can make an array of combo boxes! Make on ethen copy it and you will be asked if you want to make an array. Answer YES and you will get a change event with an index which is the number of the combo in the array!
If you ARE trying to call ALL X (50) CHANGE events then I assume that you have also CODE in the event procedure which is different for each combo. If that is correct then you HAVE concidered what code is needed for each. So you could just as wel make one function and call that with a number
for i = 1 to 50 YourFunction(i)
next i
PUBLIC FUNCTION YourFunction(i as integer)
SELECT CASE i CASE 1 ... CASE 2 ... . . CASE ELSE ... END SELECT
END FUNCTION
Synes godt om
Slettet bruger
21. juli 2002 - 12:27#4
Hi Terry.
I'll continue in english... ;)
I already know how to insert combo objects on fly. It can be done by using the following code: topvalue = 60 for i = 1 to 50 ActiveSheet.OLEObjects.Add(ClassType:="Forms.ComboBox.1", Link:=False, DisplayAsIcon:=False, Left:=114, Top:=topvalue, Width:=180, Height:=13.5).Select topvalue = topvalue + 20 next i
--- SNIP --
but how do I create one change-event to all of them, by using one sub, when I'm not able to use the index function ?
I have to make all this as dymaical as possible, because the user shall be able to change the number of combos to a self-chosen number.
HI newage I havent worked with VBA very much in Excel or Word, and in Access which I have worked with quite a lot it isnt quite the same!
In Access I would do something on these lines.
Sub NewControls() Dim frm As Form Dim ctlLCombo As Control Dim i As Integer
Dim intX As Integer, intY As Integer
intX = 1000 intY = 100
DoCmd.OpenForm "frmNewControls", acDesign
For i = 1 To 5 Set ctlCombo = CreateControl("frmNewControls", acComboBox, , "", "", intX + (i * 100), intY + (i * 100))
'Name the combo ctlCombo.Name = "cbo" & i 'Set the OnClick event to call MyFunction
ctlCombo.OnClick = "=MyFunction(" & i & ")"
Next i
DoCmd.Close acForm, "frmNewControls", acSaveYes
End Sub
The MyFunction looks like this
Public Function MyFunction(Index As Integer) MsgBox "Index = " & Index
End Function
Synes godt om
Slettet bruger
16. august 2002 - 19:28#8
I close this thread.
Seems not to be a solution anywhere on then net ;(
So... I'll split the point 50% / 50%.
Synes godt om
Ny brugerNybegynder
Din løsning...
Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.