Problems Creating Reports (1 Viewer)

Mona

New member
Local time
Today, 00:39
Joined
Jan 16, 2001
Messages
9
I am using Access 2000 and I am getting the following message: user defined type not defined, for the following 2 lines of code:

Dim dbs As Database
Dim tdf As TableDef


I am trying to create 1 large report that gives an agency's name as the form/report page header and a list of Names, SubAgency, and Email on the body/detail of the page.
I want to break up the large report into smaller reports based on each agency and I want create a file for each report.
I generated the following code but that was suggested by someone else but I cannot get it to work. I have very little VB experience. Any suggestions on how to procede or why I am getting this message?

Public Sub PrintAgencyReport()

Dim dbs As Database
Dim tdf As TableDef
Dim rstAgency As Recordset
Dim strWhere As String
Dim strReportName As String
Dim strFileName As String
Dim rstTestForRecords As Recordset
Dim strWhereTest As String
' Return reference to current database
Set dbs = CurrentDb

' Return reference to Agency table
Set tdf = dbs.TableDefs!Table1

' Open the AgencyList table containing agencies
Set rstAgency = dbs.OpenRecordset("Table1")

' Loop through AgencyList table to get the agency _
parameter for the report and path to send report

With rstAgency
.MoveFirst
Do Until .EOF
strReportName = "Report1"
strWhere = "[Agency]='" & ![Agency] & "'"
strFileName = "c:\FDLEfiles" & ![Agency] & "Report1.html"
strWhereTest = "Select * From qryReport1 Where" & strWhere
Set rstTestForRecords = dbs.OpenRecordset(strWhereTest)
If rstTestForRecords.BOF And rstTestForRecords.EOF Then
Else
DoCmd.OpenReport strReportName, acViewPreview, , strWhere
DoCmd.OutputTo acOutputReport, strReportName, "HTML(*.html)", strFileName
DoCmd.Close
End If
.MoveNext
Loop
.Close
End With
End Sub
 

Users who are viewing this thread

Top Bottom