ListBox with VBA is a nightmare? 
Author Message
 ListBox with VBA is a nightmare?

I recently found out that populating listboxes/combo boxes in VBA for Access
97 is quite different than it is in VB.  In fact, I have no idea how to do
it.  I am trying to populate a listbox with all available tables in a
specific database.  In VB I would do the following using the AddItem method:

Dim TDef as TableDef
Dim DB as Database

Set DB = OpenDatabase(App.path & "\Accounting.mdb")

For each TDef in DB.TableDefs
    If InStr(left(TDef.Name, 4), "MSys") = 0 then Listbox.AddItem
(TDef.Name) 'excludes system tables
Next

The code examples in VBA have you adding a controlbar, whatever the heck
that is, to use the AddItem method. More importantly, the examples don't
work.  Please help!



Tue, 06 Nov 2001 03:00:00 GMT
 ListBox with VBA is a nightmare?

Quote:
> Dim TDef as TableDef
> Dim DB as Database

> Set DB = OpenDatabase(App.path & "\Accounting.mdb")

> For each TDef in DB.TableDefs
>     If InStr(left(TDef.Name, 4), "MSys") = 0 then Listbox.AddItem
> (TDef.Name) 'excludes system tables
> Next

lstBox.RowSource = ""
For Each TDef in DB.TableDefs
    If InStr(left(TDef.Name, 4), "MSys") = 0 Then _
         lstBox.RowSource = lstBox.RowSource & TDef.Name & ";"
Next

Row Source Type would be set to Value List vs.Table/Query or Field List

Regards,
Don



Wed, 07 Nov 2001 03:00:00 GMT
 ListBox with VBA is a nightmare?


Dons, method will work, but the rowsource property is limited to 2000
characters. Look up RowSourceType property in the Access HELP index
and select Display. Select the first option "Create a list box or
combo box that gets it's rows from a function" and check out the
example. It's not very intuitive, but avoids the other approaches
limitations.

Quote:
>I recently found out that populating listboxes/combo boxes in VBA for Access
>97 is quite different than it is in VB.  In fact, I have no idea how to do
>it.  I am trying to populate a listbox with all available tables in a
>specific database.  In VB I would do the following using the AddItem method:

>Dim TDef as TableDef
>Dim DB as Database

>Set DB = OpenDatabase(App.path & "\Accounting.mdb")

>For each TDef in DB.TableDefs
>    If InStr(left(TDef.Name, 4), "MSys") = 0 then Listbox.AddItem
>(TDef.Name) 'excludes system tables
>Next

>The code examples in VBA have you adding a controlbar, whatever the heck
>that is, to use the AddItem method. More importantly, the examples don't
>work.  Please help!

               ...joe maki
               Matthew Tanner Kupp & Associates



Sun, 11 Nov 2001 03:00:00 GMT
 
 [ 3 post ] 

 Relevant Pages 

1. Print Text from Listbox to Printer in VBA ????

2. VB3: Setting listbox based on value of other listbox

3. Help Needed How I Create Listbox That Look Like Multi Column Listbox

4. Store Text in Listbox.Editing, and storing in Listbox

5. SetFocus to listbox B after a DblClick in listbox A

6. Nationwide-239587--ORACLE-Developer 2000-VBA-Visual Basic-Java-Oracle, VB/VBA, Java Developer

7. I am getting this message when i am tring to export or import anything using

8. error ORA-01855: AM/A.M. or PM/P.M. required

9. Busy Day = Slowdown from 12 AM - 5 AM

10. Use of @am, Am I dumb?

11. Nightmare Question

12. ODBC Nightmare


 
Powered by phpBB® Forum Software