Results 1 to 2 of 2
  1. #1
    Join Date
    Jul 2004

    Unanswered: select fields for report

    Hi all,
    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.SetWarnings False
    DoCmd.RunSQL ("Delete * from TableFields")
    DoCmd.SetWarnings True
    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
    End If
    Next fld
    Set dbs = Nothing

    Exit Sub
    Last edited by vimin2j; 07-13-04 at 10:27.

  2. #2
    Join Date
    Jul 2004


    Please ignore this message.
    I already have my answer. Thanks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts