Results 1 to 6 of 6
  1. #1
    gangel is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jun 2014
    Posts
    194

    Dates for report going CRAZY (Aus then USA)

    ok so!!!

    I have a macro that brings up a report based on the date of certain 'claims'.

    ="[ClaimDate] > #" & [StartDate] & "#"

    HOWEVER it only works if the first number is bigger than 12, otherwise it thinks in AMERICAN!!



    I use dd/mm/yyyy in my table which has a query that this is linked to.

    however if i search for 1/5/14 it shows ALL claims after January (it uses the 1 as the month)
    But if i use the same box on my form and type 13/5/14 it will find all claims after 13th MAY which is what i actually want!!!!

    OMG i literally dont know why its trying to use USA dates!!!??

    All my text boxes (for parameters) and tables and reports are set to SHORT DATE.

    PLEASE point me in the right direction, im SOOOO FRUSTRATED

  2. #2
    pbaldy's Avatar
    pbaldy is online now Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,530
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    gangel is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jun 2014
    Posts
    194
    Hey pbaldy,
    Thanks for the response,

    I found that page and i did read it but my coding is so bad I didnt really understand how to implement it.

    Below is my macro converted to VBA using the access converter. I'm trying to do this so i can learn vba from what i know I made the macro with.
    Pretty much i have 2 text boxes (StartDate and EndDate) and i want to know all the Claims in a report between those dates.

    Im saying if there is no date, then show msg box, if no end date is used, then use today (using temp var as the end date parameter)

    So where should i put the secnd lot of code to make this work correctly?

    It is important to note that my system format is Australian (dd/mm/yyyy)

    The tables are all working correctly as dd/mm/yyyy so its just a matter of getting the dates on the form correctly understood in the vba codes.

    Code:
    Function Macro1()On Error GoTo Macro1_Err
    
    
        With CodeContextObject
            If (IsNull(.StartDate)) Then
                Beep
                MsgBox "Please Enter Start Date", vbOKOnly, "No Date Entered"
                End
            End If
            TempVars.Add "TempEndDate", .EndDate
            If (IsNull(.EndDate)) Then
                TempVars.Add "TempEndDate", Now()
            End If
            DoCmd.OpenReport "TotalPaymentsMade", acViewReport, "", Eval("""[ClaimDate] Between #"" & [StartDate] & ""#"" & "" AND #"" & [TempVars]![TempEndDate] & ""#"""), acNormal
        End With
    
    
    
    
    Macro1_Exit:
        Exit Function
    
    
    Macro1_Err:
        MsgBox Error$
        Resume Macro1_Exit
    
    
    End Function
    Code:
    Format([Dates],"mm/dd/yy")



  4. #4
    pbaldy's Avatar
    pbaldy is online now Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,530
    You'd wrap [StartDate] and [TempVars]![TempEndDate] in the Format() function. Not sure why you need Eval() though, and all of the extra quotes.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  5. #5
    gangel is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jun 2014
    Posts
    194
    hey again,
    That is just what access did when it converted macro to VBA...

    I dont even know how to run that function, do i have to add Sub or something??

  6. #6
    pbaldy's Avatar
    pbaldy is online now Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,530
    I would expect it to be behind a button or some other event:

    http://www.baldyweb.com/FirstVBA.htm
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Dlookup driving me crazy
    By NJMike64 in forum Modules
    Replies: 3
    Last Post: 04-19-2014, 01:58 PM
  2. Replies: 10
    Last Post: 08-29-2013, 09:21 PM
  3. Crazy Counting
    By gbharris in forum Queries
    Replies: 1
    Last Post: 08-31-2011, 03:07 PM
  4. Report issue driving me crazy
    By Grofica in forum Reports
    Replies: 11
    Last Post: 01-28-2011, 11:23 AM
  5. Autonumber gone crazy
    By asearle in forum Access
    Replies: 1
    Last Post: 07-27-2010, 05:41 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums