Log in

View Full Version : VBA code changing from mm:dd:yyyy to dd:mm:yyyy



ZUM8
11-12-2010, 12:17 AM
Hi

In Denmark vi use date format dd:mm:yyyy

I have a VBA code, which is not working correct, because VBA use the format mm:dd:yyyy

Is it possible to add a string, to this vba code so it will work with all country format.?


Private Sub Form_Open(Cancel As Integer)
Dim VARa As Date
VARa = DMax("[Date_Log]", "Daily Report")
If DCount("*", "Daily Report", "[date_log]= #" & Date & "#") = 0 Then
DoCmd.GoToRecord acForm, "daily report", acNewRec
DoCmd.GoToControl "planner"
Else:
Me.Date_log.SetFocus
DoCmd.FindRecord VARa, acEntire, False, , True, acCurrent, True
DoCmd.GoToControl "planner"
End If


Regards

ZUM8

hansup
11-12-2010, 04:46 AM
Submit the literal date value to the database engine in an unambiguous date format.

If DCount("*", "Daily Report", "[date_log]= #" & Format(Date, "yyyy/mm/dd") & "#") = 0 Then

HiTechCoach
11-12-2010, 02:10 PM
Is [date_log] a date/time data type?

See if this helps:

International Dates in Access (http://allenbrowne.com/ser-36.html)

ZUM8
11-12-2010, 09:17 PM
Tks for your help.

If DCount("*", "Daily Report", "[date_log]= #" & Format(Date, "yyyy/mm/dd") & "#") = 0 Then

Worked perfect.

Regards ZUM8