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:
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?
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: