Read data from DB into combobox? 
Author Message
 Read data from DB into combobox?

Hello M8s,

I want to read data from a Access DB into a combobox of
a word userform. But dont know how.
I know this is done in VBasic like i pasted below.

--
Dim db As Database
Dim rs As Recordset
Set db = OpenDatabase("c:\db1.mdb")
Set rs = db.Openrecordset("select * from table1")
Do While rs.EOF <> True
    combobox.AddItem rs(0)
    rs.Movenext
Loop
--

If someone out there knows how, please reply!

What i need is that a user can fill in telephone
numbers in a form that will be written into a bookmark
of a document.

Because there are lots of those numbers and they are hard
to remember. I thougt to place 2 buttons below the combobox
"delete nr." & "add nr." So this would be stored in the DB.

Or maybe somone knows how to do this using flat text files?
Or somone has a link to documentation about this stuff.

Anyway,
Need some dopeh :)
Regards & Have a nice weekend!!



Tue, 28 Oct 2003 23:52:20 GMT  
 Read data from DB into combobox?
Hi ThaDopeHdEaLer,

Well, basically you do it the same way. A couple of tips:

1) You need to set a reference in Tools/References to DAO.
Then you should also declare your object variables with
this: Dim db as DAO.Database, for example.

Quote:
> I want to read data from a Access DB into a combobox of
> a word userform. But dont know how.
> I know this is done in VBasic like i pasted below.

> --
> Dim db As Database
> Dim rs As Recordset
> Set db = OpenDatabase("c:\db1.mdb")
> Set rs = db.Openrecordset("select * from table1")
> Do While rs.EOF <> True
>     combobox.AddItem rs(0)
>     rs.Movenext
> Loop
> --

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister
http://www.mvps.org/word
http://go.compuserve.com/MSOfficeForum

This reply is posted in the Newsgroup; please post any
follow question or reply in the newsgroup and not by e-mail
:-)



Sat, 01 Nov 2003 00:41:22 GMT  
 Read data from DB into combobox?

says...

Hi Cindy,

It was the same way. And indeed i didn't know
that i had to set that reference. Now i have some other
problems.

1. How can i auto set this reference for all the users
on witch i will install my template?

2. How do i sort the combobox data in alphabetic order.
The data is read from an field in a database table.
I've looked on the net and i came along a workaround
with arrays. And me know so little about this :(
Is there no other solution.. like sort the data in the table
first and then read it in?

Hope to hear from you.
Thanks for replying!

krgds,
REL.

Quote:
> Well, basically you do it the same way. A couple of tips:

> 1) You need to set a reference in Tools/References to DAO.
> Then you should also declare your object variables with
> this: Dim db as DAO.Database, for example.
> > I want to read data from a Access DB into a combobox of
> > a word userform. But dont know how.
> > I know this is done in VBasic like i pasted below.

> > --
> > Dim db As Database
> > Dim rs As Recordset
> > Set db = OpenDatabase("c:\db1.mdb")
> > Set rs = db.Openrecordset("select * from table1")
> > Do While rs.EOF <> True
> >     combobox.AddItem rs(0)
> >     rs.Movenext
> > Loop
> > --



Sat, 01 Nov 2003 20:15:55 GMT  
 Read data from DB into combobox?

Cindy,

Thanks, the sorting worked perfectly with the SQL line.

Well, when i am done with my templates and ready to install
them and getting that DLL conflicts. Then i'll know where
to find you ;)

Thanks again for your help!!

krgrds,
REL.



Sat, 01 Nov 2003 22:13:58 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. Filling a ComboBox with data from DB

2. Copy Data Structures no data DB to DB

3. Data Control + DBComboBox Makes DB Read-Only ????

4. Read data from DB, write to registry via VBscript

5. overFlow error in VB while reading data from DB

6. read/write bitmap data to an ORACLE db in VB50

7. Reading Access 2.0 db on network w/read-only access

8. Copying data from one DB to another DB

9. export data from one access db to same db on another machine using vb6

10. Copy table schema and data from one DB to another DB

11. Active Data db V.S. DataWarehouse db

12. ComboBox looks to another db

 

 
Powered by phpBB® Forum Software