Hi,
am developing a Payroll Program. I have created a Database Table in Ms Access 2000. I have placed Text Box controls on my Vb 6 Form including a Combo box.
I want to fill the combo box with employee names when the Form loads. I have tried to write codes that will do this, but can't get it done.
Please kindly assist me. What is wrong with the following codes?:
Private Sub Form_Load()
With adoSubjects.Recordset
Do Until Not .EOF
If !SubjectCode <> "" Then
cboSubjects.AddItem !SubjectCode
End If
.MoveNext
Loop
.Close
End With
Thanks.
Akinyemi.
Would it not be simpler to set you combo box source to a table/query type then set the rowsource to the SQl string, followed by a requery,
The following code works for me;
Private Sub Frame38_Click()
Dim a As Variant:
a = Me.Frame38.Value
Select Case a
Case 1
strSQL = "SELECT Cat.Index, Cat.Category FROM Cat;"
Case 2
strSQL = "SELECT [Position].[Index], [Position].[Position] FROM [Position]; "
End Select
Me.List43.RowSource = ""
Me.List43.RowSource = strSQL
Me.List43.Requery
End Sub
Though this is used in frame, the priciple is the same, as a button is selected the rowsource of the unbound list bow is removed, changed, the refreshed to show the changes.
This allows you to change the contents of the list box/combo box on the fly, depending on the status of the buttons, The only thing to remember is to include the index of your table (should be numerical), and the format of you list box/combo box you can elect to either show or hide the index number. This can be done as an onload feature, thus giving up to date list in the combo box. I just use the option box selected number and the number of the combo box when refering to an item later on.
Hope this helps, or maybe I've just got the wrong end of your stick.....
Alan Hill