Consulting

Results 1 to 4 of 4

Thread: VBA code changing from mm:dd:yyyy to dd:mm:yyyy

  1. #1
    VBAX Newbie
    Joined
    Nov 2010
    Posts
    2
    Location

    VBA code changing from mm:dd:yyyy to dd:mm:yyyy

    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

  2. #2
    VBAX Mentor
    Joined
    Feb 2009
    Posts
    447
    Location
    Submit the literal date value to the database engine in an unambiguous date format.

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

  3. #3
    Is [date_log] a date/time data type?

    See if this helps:

    International Dates in Access
    Boyd Trimmell aka HiTechCoach
    Microsoft Access MVP -2010-2015

    Programming: Nine different ways to do it right, a thousand ways to do it wrong.
    Binary--it's as easy as 1-10-11

  4. #4
    VBAX Newbie
    Joined
    Nov 2010
    Posts
    2
    Location
    Tks for your help.

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

    Worked perfect.

    Regards ZUM8

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •