calling subroutine

  • Thread starter Thread starter Lodewijk
  • Start date Start date
L

Lodewijk

I have a sub-routine that fills in a combobox:

Sub Box(FN, ComboBox, Waarde)
With ComboBox
Do While Not EOF(FN)
Input #FN, MyString
.AddItem MyString
Loop
End With
For teller = 1 To ComboBox.ListCount
If ComboBox.List(teller) = Waarde Then
ComboBox.Text = ComboBox.List(teller)
End If
Next teller
End Sub

I want to use this to fill in all the comboboxes on my form. By calling this
with Call Box(FNBriefLayout, cboBriefLayout, MyUser(10, 3)), where
FNBrieflayout is the FileNumber, and cboBriefLayout is the name of the
combobox, It will not work.
But when I replace cboBriefLayout with "cboBriefLayout" it also does not
works.
How do I call this subroutine so that "With ComboBox" will be the same as
"With cboBriefLayout"?


Lodewijk
 
Lodewijk said:
I have a sub-routine that fills in a combobox:

Sub Box(FN, ComboBox, Waarde)
With ComboBox
Do While Not EOF(FN)
Input #FN, MyString
.AddItem MyString
Loop
End With
For teller = 1 To ComboBox.ListCount
If ComboBox.List(teller) = Waarde Then
ComboBox.Text = ComboBox.List(teller)
End If
Next teller
End Sub

I want to use this to fill in all the comboboxes on my form. By calling this
with Call Box(FNBriefLayout, cboBriefLayout, MyUser(10, 3)), where
FNBrieflayout is the FileNumber, and cboBriefLayout is the name of the
combobox, It will not work.
But when I replace cboBriefLayout with "cboBriefLayout" it also does not
works.
How do I call this subroutine so that "With ComboBox" will be the same as
"With cboBriefLayout"?


Since you declared the Sub's arguments as Variants, you are
letting Access guess whether you want the combo box object
or its value. It looks like it guessed wrong.

Sub Box(FN As Integer, ComboBox as ComboBox, Waarde As
String)

Note the ambiguity of using the name ComboBox for the second
argument.

Without putting any serious thought into this, I suspect
there's a simpler/cleaner way to get a combo box to use a
text file as a combo's RowSource. Maybe you could link to
the text file??
 
Back
Top