Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

select fields for report

Status
Not open for further replies.

Vimin2j

Technical User
Jul 7, 2004
6
US
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:

[COLOR=red yellow]Private Sub cboTable_AfterUpdate()[/color]
On Error GoTo Err_cboTable_AfterUpdate

Dim [COLOR=yellow blue]dbs As DAO.Database[/color] ,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.AddNew
rst!FieldName = fld.Name
rst!FieldType = fld.Type
rst.Update
End If
Next fld
Set dbs = Nothing
'cboFieldName1.Requery
'cboFieldName2.Requery
'cboFieldName3.Requery
lstLocalAuthority.Requery
'reset

Exit_cboTable_AfterUpdate:
Exit Sub


 
Hi

Check you have a reference to the DAO library

To do this, open any code module in design view, choose Tools\refrences from the menu, look down the lsit of selected libraries, if DAO is not present, select it

Regards

Ken Reay
Freelance Solutions Developer
Boldon Information Systems Ltd
Website needs upgrading, but for now - UK
 
Thanks a bunch!!!
I totally got it. Thank u again
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top