|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
SlickEdit: Code in over 40 languages across 7 platforms. SlickEdit’s unmatched power, speed, and flexibility allows even the most accomplished developers to write better code faster. Download a free trial today! |
|
#1
|
|||
|
|||
|
Accessing an Access DB with VB
I am setting up a VB form that connects to multiple tables in an Access DB. My connections are all good and work well but the problem is with my combo boxes.
If, for instance, I have a drop down called "Ice Cream Flavors" and the values are "Vanilla", "Chocolate", and "Strawberry", my combo box only shows "Vanilla" and doesn't show the other two in the drop-down. (Drop down is blank) Instead, I have to use the ADO arrows to make the data move. Is there anyway I can change it so that the information can be seen on a drop down instead of by clicking those darn arrows??? THANKS |
|
#2
|
|||
|
|||
|
Try something like this:
Option Explicit Dim MyConnection as String Form_load() MyConnection = "C:Where ever database is /database.mdb" Call FillCmbList End sub Private Sub FillCmbList Dim db As Database Dim ws As Workspace Dim Rst As DAO.Recordset Set ws = DBEngine.Workspaces(0) Set db = ws.OpenDatabase(MyConn) Set Rst = db.OpenRecordset("SELECT * FROM (tablename) ORDER BY (main field)", dbOpenDynaset, dbReadOnly) Do While Not Rst.EOF CmbDr.AddItem Rst.Fields("Main Field") Rst.MoveNext Loop End sub
__________________
Best regards, Russ Bergen Senior Software Developer and Webmaster |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > Visual Basic Programming > Accessing an Access DB with VB |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|