List Box

lessthanme5

Registered User.
Local time
Today, 21:59
Joined
Mar 7, 2006
Messages
43
Hi I am having trouble trying to find some code that lists the fields in a selected table (which is in a list box its self.)

I can list the tables but what I really need is for the table to update a list box with its own individual fields.

does anyone know what I mean and can you help?
 
Hello:
Below is a subroutine that works for me.
It lists all the fields from a selected table in a list box called lstAvailableTables and places then in another list box called lstAvailableFields.
'
Public Sub LoadFields()
'Author: Mark Hartman
'Purpose:
'Comments:
'
On Error GoTo Procedure_Error
Dim db As Database
Dim rs As DAO.Recordset
Dim fld As Field
Dim strRowSource As String
'
Set db = CurrentDb()
Set rs = db.OpenRecordset(lstAvailableTables.Value)
'
For Each fld In rs.Fields
strRowSource = strRowSource & """" & fld.Name & """;"
Next fld
lstAvailableFields.RowSource = strRowSource
'
rs.Close
CurrentDb.Close
'
Exit_Procedure:
Exit Sub
'
Procedure_Error:
Beep
MsgBox "Error " & Err.Number & ": " & Err.Description
Resume Exit_Procedure
End Sub
'
Regards
Mark
 

Users who are viewing this thread

Back
Top Bottom