Populate ListBox

S

shapper

Hello,

I created a form, named fObras, in Access 2007 with a ListBox named
lbObras.

Then I created a Module to populate the lbObras with the column Name
taken form the table "Obras" in the database 'Fornecedores 2007.mdb".

When I run the form nothing happens. What am I doing wrong?

I think I am missing something that connects the form fObras to my
module code.

Could someone please help me out?

Thanks,
Miguel

This is my module code:

Option Compare Database

Dim dbFornecedores As Database
Dim rsFornecedores As Recordset

Private Sub Form_Load()

Set dbFornecedores = OpenDatabase("Fornecedores 2007.mdb")
Set rsFornecedores = dbFornecedores.OpenRecordset("Obras",
dbOpenDynaset)

If Not rsFornecedores.EOF Then rsFornecedores.MoveFirst
Do While Not rsFornecedores.EOF
lbObras.AddItem rsFornecedores!Nome
lbObras.ItemData(lbObras.NewIndex) = rsFornecedores!ID
rsFornecedores.MoveNext
Loop

End Sub
 
N

NetworkTrade

Are you certain you require a Module to populate the listbox?

You are aware of the simpler methods?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top