in the 3+ years I have been doing vb, I still have problems with the loop functions. Below I am trying to add an access97 database column's entries into a ComboBox on an excel form...
HHEEELLLLLLPPPPP please, I guess this is a simple one anyway & think most people here must have encountered this at one stage or another, am I slightly out in my coding, or off the planet?Code:Private Sub Workbook_Open() Dim db As Database Dim rs As Recordset Dim cmb As Object Dim i As Integer, x As Integer Dim txt As Variant Set db = OpenDatabase("C:\A_Database.mdb") Set rs = db.OpenRecordset("A_Table") Set cmb = Worksheets(1).ComboBox1 txt = rs.Fields(x).Value x = 1 For i = 0 To rs.Fields.Count cmb.AddItem txt x = x + 1 Next i End Sub
Thank you everyone!
Alex Read




Reply With Quote