If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
Run-time error '13': Type mismatch
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 HE Type mismatch MsgBox rst.RecordCount rst.Close Set dbs = Nothing End Sub |
#2
|
|||
|
|||
Run-time error '13': Type mismatch
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 -- 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. "bw" wrote in message ... 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 HE Type mismatch MsgBox rst.RecordCount rst.Close Set dbs = Nothing End Sub |
#3
|
|||
|
|||
Run-time error '13': Type mismatch
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 "Allen Browne" wrote in message ... 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 -- 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. "bw" wrote in message ... 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 HE Type mismatch MsgBox rst.RecordCount rst.Close Set dbs = Nothing End Sub |
Thread Tools | |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
how do i type a time into a cell formatted for time? | Armadillo | General Discussion | 4 | June 16th, 2005 11:32 PM |
Data Type Mismatch problem | SMelissaK | General Discussion | 0 | February 24th, 2005 07:03 PM |
Outlook 2003 Terminal Server Time Zone issue | Robert Strom | Calendar | 2 | May 26th, 2004 10:50 PM |
Trying to count the number or customers of type x for subsequent time intervals | Earl Kiosterud | Worksheet Functions | 0 | May 3rd, 2004 05:05 AM |