I have posted this question ealier, but I think I didn't make it clear enough.
I'm creating a form where users can choose field(s) for a report. What I try to do is when users select a table name, all fields in that table will show up in a list box, but when I select one, there is an error message.
It said, Compile error: User-defined type not define
I don't know how to fix it. Please help!!!
Here is the code: (errors shown in hightlight)
Private Sub cboTable_AfterUpdate()
On Error GoTo Err_cboTable_AfterUpdate
Dim dbs As DAO.Database, tdf As DAO.TableDef
Dim fld As DAO.Field, rst As DAO.Recordset
Dim tbl As String
tbl = Forms!frmLocalAuthority!cboTable
' Return reference to current database.
Set dbs = CurrentDb
' Return reference to Employees table.
Set tdf = dbs.TableDefs(tbl)
DoCmd.RunSQL ("Delete * from TableFields")
Set rst = dbs.OpenRecordset("TableFields", dbOpenDynaset)
' Enumerate all fields in Fields collection of TableDef object.
For Each fld In tdf.Fields
If fld.Type >= 1 And fld.Type <= 8 Or fld.Type = 10 Then
rst!FieldName = fld.Name
rst!FieldType = fld.Type
Set dbs = Nothing