Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Populating a Combo Box 1

Status
Not open for further replies.

carpetbelly

Technical User
Jun 12, 2003
202
GB
Hi,

I'm struggling with a bit of code in my database at the moment.

Unless it's a reference error I cannot see why it isn't working (tuesday morning blues otherwise hehe)

I just cannot get the .additem to work. It isn't even an option to do on my combo box.

Code:
Private Sub form_load()
Set mc = New clsMonthCal
mc.hWndForm = mc.hWnd
Me.txtEndDate.Enabled = False



Set cnn = CurrentProject.Connection

Set rst = New ADODB.Recordset
rst.Open "SELECT [StaffName] FROM tblStaff ORDER BY [StaffName];", cnn, adOpenStatic
rst.MoveLast
rst.MoveFirst

With Me.cmbName.Value = ""
        Do
            .additem rst![StaffName]
            rst.MoveNext
        Loop Until rst.EOF
End With

End Sub
 
Should it be

WHILE Me.cmbName.Value = ""
Do
.additem rst![StaffName]
rst.MoveNext
Loop Until rst.EOF
End WHILE

but why not simply

SET Me.cmbName.recordset = rst


Regards

Ken Reay
Freelance Solutions Developer
Boldon Information Systems Ltd
Website needs upgrading, but for now - UK
 
Thanks for that, at least that's what I tried at first. I cant seem to have access to the .rescordset property of the combo box or to perform .additem either.
 
Hi...

Prior to version Access 2002, the additem method was not available.(straight form Microsoft)

You should probably use rowsource property when assigning a recordset to a combobox(personal preference)

 
Ahhh typical, serves me right for using 2002 at home and in my new job being given 2000 =P
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top