Run Time error '13'

Mona

New member
Local time
Today, 06:21
Joined
Jan 16, 2001
Messages
9
I get a run time error '13' message for the following line:type mismatch

Set rstAgency = dbs.OpenRecordset("Table1")

Why am I getting this message.

This is the coding I generated:
Option Compare Database


Public Sub PrintAgencyReport()

Dim dbs, Database
Dim tdf, 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
 
Should you not be doing this?

Dim dbs AS database
not
Dim dbs,database
and the same for rst?

Also I see no reference to the tdf object in your code so why is it referenced?

I'm not really sure about this but I think you also need to put () after CurrentDb. I could be wrong though.

Ian
 

Users who are viewing this thread

Back
Top Bottom