Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Reports / Printing / December 2005

Tip: Looking for answers? Try searching our database.

Run-time error '13':  Type mismatch

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
bw - 04 Dec 2005 10:36 GMT
I call this procedure from the Report_Open event, and am getting the error
shown on the 6th line below.
I'm trying to find out how many records (if any) are in the table
"tblSelectMainReport".
Can you explain the error, or a better way to find out the number of records
in the table?

Thanks,
Bernie

Private Sub CountTheErrors()
Dim dbs As Database, rst As Recordset, X As Integer, strName As String
Dim strDocName As String
   Set dbs = CurrentDb
   strDocName = "tblSelectMainReport"
    Set rst = dbs.OpenRecordset(strDocName) 'ERROR HERE: Type mismatch
   MsgBox rst.RecordCount
   rst.Close
   Set dbs = Nothing
End Sub
Allen Browne - 04 Dec 2005 10:55 GMT
Try:
   Dim dbs As Database, rst As DAO.Recordset, X As Integer, strName As
String

Both the DAO library and the ADO library have a Recordset object. If you do
not specify which one you want, you get whichever one is listed first under
Tools | References (from a code window.)

You can solve the problem by any of the following:
a) Remove the ADO library if you don't need it.
b) Move the DAO library above ADO so it has a higher priority.
c) Explicitly disambiguate, as in the example above.

More info on which references are needed for which versions of Access:
   http://allenbrowne.com/ser-38.html

Signature

Allen Browne - Microsoft MVP.  Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

>I call this procedure from the Report_Open event, and am getting the error
>shown on the 6th line below.
[quoted text clipped - 16 lines]
>    Set dbs = Nothing
> End Sub
bw - 04 Dec 2005 13:30 GMT
Thanks,Allen!

I was going to follow up with more questions about this, but I guess you new
I would, and so included the link to your explanation for "Solving Problems
with Library References".

As always, I appreciate your help.
Bernie

> Try:
>    Dim dbs As Database, rst As DAO.Recordset, X As Integer, strName As
[quoted text clipped - 32 lines]
>>    Set dbs = Nothing
>> End Sub
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.