Access upload date format

aespinoza

New Member
Joined
Mar 1, 2017
Messages
11
Hi All

The problem i have is.
i have created an excel file with a userform that is a questionnaire.
with in this questionnaire are several section where a date is required.
once the userform is submitted a worksheet has cells filled in with the userform values. no problems here
the problem arises when I try to upload this sheet to an access database. it actually all works apart form at the beginning of the month. the dates are entered as DD/MM/YYYY but this somehow defaults into the Database as MM/DD/YYYY
Code:
Dim cn As ADODB.Connection
Dim rs As ADODB.Recordset
Dim x As Long
Dim y As Long
Set cn = New ADODB.Connection


cn.Open "Provider=Microsoft.ACE.OLEDB.12.0;" & _
"Data Source=" & "Y:\Contact Centre\03 - Team Leaders & Support\01 - Contact Centre MI\MI Suite\Do Not Use\MI Database Quality.accdb;"




'select DB table to add records to
Set rs = New ADODB.Recordset
rs.Open "Compliance", cn, adOpenKeyset, adLockOptimistic, adCmdTable


y = 2
Do Until y = 6
'add new record
rs.AddNew


rs.Fields("Survey_ID") = Cells(y, 1).Value
rs.Fields("Q1") = Cells(y, 2).Value
rs.Fields("Q2") = Cells(y, 3).Value
rs.Fields("Q3") = Cells(y, 4).Value
rs.Fields("Q4") = Cells(y, 5).Value
rs.Fields("Date_of_ Interaction") = Cells(y, 6).Value
rs.Fields("Time_of_Interaction") = Cells(y, 7).Value
rs.Fields("Department") = Cells(y, 8).Value
rs.Fields("Workstream") = Cells(y, 9).Value
rs.Fields("Call") = y - 1

the date_of_interaction field is the problem
I have tried the following
Code:
rs.Fields("Date_of_ Interaction") = Format(Cells(y, 6).Value, "dd/mm/yyyy")

any help would be greatly appreciated

Thanks
 

Excel Facts

How to calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a $25,000 loan, 5% annual interest, 60 month loan.
if Access is set to US dates, this can fail with invalid dates.
convert the cell to US date or convert to long integer. (all dates are numeric)
once saved, you can always view the dates in any format
"dd/mm/yyyy"
 
Upvote 0
Try using the format yyyy-mm-dd, it's kind of an international standard thing.
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,177
Members
453,021
Latest member
Justyna P

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