Results 1 to 5 of 5
  1. #1
    RyanP is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Feb 2012
    Posts
    60

    Copy Date Fields via VBA - Comply with input mask settings

    Hello'

    I have all the date fields in an app set to use the ISO format for short (numeric only) dates. Everything is fine on the forms & reports (regardless of your settings, they are YYYY-MM-DD (as it always should be for numeric only dates ).

    During a specific report export I am copying a date field via VBA to apply it to the file name of a export.

    This works fine when the PC is also set to use the ISO format for numeric dates but fails me when any other regional settings is present. e.g. My 2015-07-15 gets converted into 07/15/2015 or 15/07/2015 or other...

    Obviously this is a fail for file names... When this occurs, the end users apparently cannot even change the file name (to remove the "/" symbol as I am getting error 2302 every time I try).

    When I am copying the date via VBA from a field with a YYYY-MM-DD format / YYYY-MM-DD input mask; how do I retain/force the source field's format / input mask?

    'Prep the Report Range Section of the File Name
    Dim strRepStart As String
    Dim strRepEnd As String
    strRepStart = Me.txtFLTRStartDate
    strRepEnd = Me.txtFLTREndDate
    'TRIM strRepEnd
    strRepEnd = Left$(strRepEnd, 10)



    strFileName = "ReportName" & "_" & strRepStart & "-" & strRepEnd & ".pdf"

  2. #2
    RyanP is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Feb 2012
    Posts
    60
    As for exports to Excel, I am using only the basic OutputTo command for Excel exports as well, so I suppose I can't fix it in the excel exports without first changing how I export to Excel. (not really an issue with the excel table...really just the file names (mandatory as "/" symbols can't be in file names) & what's written to the PDF exports (want it standardized for consistency)

  3. #3
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Try this type of thing:

    strRepEnd = Format(Me.txtFLTREndDate, "yyyy-mm-dd")
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  4. #4
    RyanP is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Feb 2012
    Posts
    60
    well... that was
    Click image for larger version. 

Name:	staples EASY button.jpg 
Views:	7 
Size:	10.3 KB 
ID:	21280

    my bad... what a newb :0

  5. #5
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    LOL! Happy to help.
    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. Input Mask
    By PRHoff in forum Access
    Replies: 2
    Last Post: 02-19-2015, 09:00 AM
  2. Adding Long Date to Input Mask
    By wes9659 in forum Access
    Replies: 1
    Last Post: 02-13-2015, 01:51 PM
  3. input mask
    By slimjen in forum Forms
    Replies: 7
    Last Post: 10-07-2013, 03:20 PM
  4. Date Input Mask in Query?
    By DelbyJones in forum Access
    Replies: 3
    Last Post: 09-01-2012, 11:08 AM
  5. Custom (?) Date Input Mask
    By SeaTigr in forum Access
    Replies: 3
    Last Post: 11-07-2011, 02:40 PM

Tags for this Thread

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