Data type mismatch in criteria expression error?

cmast

New Member
Joined
Oct 23, 2015
Messages
1
I'm attempting to adapt a report written in Excel and Access to a new reporting system. Running the report is a 3 step process:

1) Generate three CSV files from our data system
2) Save these CSV files as Excel 2010 (.xlsx) files
3) the .xlsx files are imported into Access
4) Excel runs queries on the Access database.

The reporting system that generates the CSV files changed, and I'm attempting to recreate the old spreadsheets exactly using the current reporting system. I can create EXACT duplicates of the CSV files down to column names, formats of data and everything else - however, when I save the CSV files as .xlsx files and attempt to import them into the Access database, I'm getting the following VBasic error:

Run-time error '-2147217913 (80040e07)':
Data type mismatch in criteria expression.

Selecting Debug points to the bolded line in the following code:

Private Sub RunCommand()

'This subroutine fetches the query from the database and deposits
'the result into the destination cell
'(DestCell) that is identified before each call of RunCommand

Dim result As Long

cmd.CommandText = QString
Set rs = cmd.Execute
result = CLng(rs.Fields.Item(0))
If result = 0 Then
Worksheets(DestWksht).Range(DestCell) = "-"
Worksheets(DestWksht).Range(DestCell).HorizontalAlignment = xlCenter
Else
Worksheets(DestWksht).Range(DestCell) = result
Worksheets(DestWksht).Range(DestCell).HorizontalAlignment = xlRight
End If
End Sub

I've done half a dozen things to see if there was some problem with my data - made sure there was no blank cells, formatted the CSV files with quotations and without, etc and so forth, and no matter what I run into this "Data type mismatch" error. What is the problem here?
 
Last edited:

Forum statistics

Threads
1,226,835
Messages
6,193,225
Members
453,781
Latest member
Buzby

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top