|
-
Aug 31st, 2000, 09:53 AM
#1
Thread Starter
Evil Genius
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...
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
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?
Thank you everyone!
Alex Read
-
Aug 31st, 2000, 11:14 AM
#2
Member
try this:
using datacontrol
Data1.DatabaseName = App.Path & "\person.mdb"
Data1.RecordSource = "educacion"
Data1.Refresh
Data1.Recordset.MoveLast
cant1 = Data1.Recordset.RecordCount
Data1.Recordset.MoveFirst
For i = 1 To cant1
Combo3.AddItem Data1.Recordset.Fields("educacion")
Data1.Recordset.MoveNext
Next i
Combo3.ListIndex = 0
-
Sep 1st, 2000, 05:41 AM
#3
Thread Starter
Evil Genius
Cheers Carlos !!!!!!
Realised I should have used the rs.movenext (I should know that one).
I was calling this from Excel, so did not use the data control.
This helped anyway & all is working!
Thank you once again!
Alex
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|