I have created a temporary table and then want to examine the contents (1 Viewer)

atrium

Registered User.
Local time
Tomorrow, 05:07
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.
 

theDBguy

I’m here to help
Staff member
Local time
Today, 11:07
Joined
Oct 29, 2018
Messages
21,358
Try changing this:

Dim db As Database

into this:

Dim db As DAO.Database
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Today, 13:07
Joined
Feb 28, 2001
Messages
26,999
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. < / >
 

atrium

Registered User.
Local time
Tomorrow, 05:07
Joined
May 13, 2014
Messages
348
Thanks guys
sorry about the code
Your help was just what I needed to get it going properly
 

theDBguy

I’m here to help
Staff member
Local time
Today, 11:07
Joined
Oct 29, 2018
Messages
21,358
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.
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 14:07
Joined
Feb 19, 2002
Messages
42,971
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

Top Bottom