Access VBA - Date as text converts to a math division when copied

icyrius

New Member
Joined
Dec 22, 2012
Messages
15
Hello experts,

I have a text date (7/1/2015) that when copied to another table converts as a math division and pastes an integer (3.47394540942928E-03). The receiving table has been formatted to be also a text field.

This the part of the code where is pasting the record set,
Code:
DoCmd.SetWarnings False
DoCmd.RunSQL "INSERT INTO tbl_DatesbyLocation (Location,Start_Date,End_Date) VALUES (" & recordset1.Fields(0).Value & "," & recordset2.Fields(0).Value & "," & recordset2.Fields(1).Value & ")"
recordset1.MoveNext

The source table (recordset2) has dates entered as text.

Thanks for the help.
 

Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.
ON the general principle that string data needs to be enclosed in quotes, I would try:
"'" & recordset2.Fields(1).Value & "'"

Remember that you are creating a raw SQL string here, which is simply run as such.
 
Upvote 0

Forum statistics

Threads
1,215,372
Messages
6,124,532
Members
449,169
Latest member
mm424

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