How can I replace the yellow highlight with the variable "[highlight #8AE234]whichComboBox[/highlight]" which will have something like "cboChooseXXX"
Code:
Private Sub LoadComboBox(ByVal [highlight #8AE234]whichComboBox[/highlight], ByVal SQLString, ByVal AddFirstItem)
' call this like so
' Call LoadComboBox(Me.cboChooseProcedure.Name)
'clear it first
[highlight #FCE94F]Me.cboChooseProcedure[/highlight].Items.Clear()
Dim strConn As New SqlConnection(gblConnectionString)
Dim objComm As SqlCommand
Dim objReader As SqlDataReader
strConn.Open()
objComm = New SqlCommand(SQLString, strConn)
objReader = objComm.ExecuteReader()
If AddFirstItem <> "" Then
[highlight #FCE94F]Me.cboChooseProcedure[/highlight].Items.Add(AddFirstItem)
End If
If objReader.HasRows Then
Do While objReader.Read()
[highlight #FCE94F]Me.cboChooseProcedure[/highlight].Items.Add(objReader.GetString(0))
Loop
End If
'select 1st item in list
[highlight #FCE94F]Me.cboChooseProcedure[/highlight].SelectedIndex = 0
End Sub
DougP