I have created a temporary table and then want to examine the contents

atrium

Registered User.
Local time
Today, 17:34
Joined
May 13, 2014
Messages
348
I have created the temp table from a query, the records in the table are what I want, but when I go to the Set db = CurrentDb I get a data Run Time error 13 Type Mismatch error.

I have checked the names of the fields and their type on the query against the temp table and they are fine.

Dim strQryFile As String
Dim strQryFileSql As String
Dim db As Database
Dim RecCounter As Integer
strQryFile = "DdTransTemp"
strQryFileSql = "SELECT * INTO DdTransTemp FROM DdSelectTransInRangeQry; "

DoCmd.SetWarnings False
DoCmd.RunSQL strQryFileSql
DoCmd.SetWarnings True

Dim rs As DAO.Recordset
Dim lUserID As Long
DBEngine.SetOption dbMaxLocksPerFile, 1000000
On Error GoTo ErrTrap
TaskCompletedFld = 0

Me.QryFile = strQryFile
lUserID = Me.UserIdFld.Value
Set db = CurrentDb

The last line is the one that creates the error. If I try to view it's contents (CurrentDb) in the immediate window I get the same thing

Anyone have any ideas about it.
 
Try changing this:

Dim db As Database

into this:

Dim db As DAO.Database
 
For the record I would have edited that code to have code tags but there is no particular convoluted logic in it.

Even so, @atrium, please take this as a gentle reminder that if you are going to post code, you need to enclose what you post in code tags. It is the item in the menu/effects bar above the individual post that looks like less-than, slash, greater-than. < / >
 
Thanks guys
sorry about the code
Your help was just what I needed to get it going properly
 
Thanks guys
sorry about the code
Your help was just what I needed to get it going properly
Hi. We're all happy to assist. Good luck with your project.
 
1. It is rarely necessary to make temp tables. They cause bloat and so should be avoided at all costs. In this case, just open the query if you want to examine the data.
2. Your code isn't actually reading the temp table. What are you trying to do with the temp data?
 

Users who are viewing this thread

Back
Top Bottom