Run-time Error '-2147352571 (80020005)': Type mismatch

g8rbroker

New Member
Joined
Sep 3, 2008
Messages
15
Hi All,

I am having an issue while trying to write to an Access database using VBA. I receive the error on the line below.

.Fields("BILL CALC DONE") = varVF_BillCalcDone

The field in Access where this is trying to write to is listed as a Yes/No field. Is there a conversion function or something else that I should be using? Please help.

Thanks.
 

Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.
try:
Code:
.Fields("BILL CALC DONE") = CBool(varVF_BillCalcDone)
 
Upvote 0
.Fields("BILL CALC DONE") = CBool(varVF_BillCalcDone) didn't work. I now get a Run-time error ' 13': Type mismatch.
 
Upvote 0
That would suggest that the value of varVF_BillCalcDone cannot be converted to a True/False value. What is its value?
 
Upvote 0
The cell in Excel is always either Yes or No. Therefore, I am trying to write either the word "Yes" or "No" to the database.
 
Upvote 0
Code:
Fields("BILL CALC DONE") = (varVF_BillCalcDone = "Yes")
should work I think.
 
Upvote 0
You can't pass a String to Access like this, Yes/No in Access is a clever guise for a Boolean, it needs to be True or False, or any number = True (-1 is your best bet) and 0 = False.

So create an If Statement in your code, If X = Yes then pass True, Else, False.

Edit: Rory's way is better, that creates your Boolean. :)
 
Last edited:
Upvote 0

Forum statistics

Threads
1,214,985
Messages
6,122,606
Members
449,089
Latest member
Motoracer88

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