Results 1 to 5 of 5
  1. #1
    Summit_IT is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Jan 2019
    Location
    Virginia
    Posts
    47

    Change date format to yyyy in a combined field value within a query or form.

    I have a textbox in a form with the Control Source "="SH-OH-" & [DocumentYear] & "-" & [8130-3_ID]".

    The result = SH-OH-10/31/2023 3:51:44-786.



    I need result =SH-OH-2023-786.


    Thanks!

  2. #2
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows 10 Access 2019
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,544
    Perhaps something like:

    "="SH-OH-" & Year([DocumentYear]​) & "-" & [8130-3_ID]".
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  3. #3
    Summit_IT is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Jan 2019
    Location
    Virginia
    Posts
    47
    Hi Bob,

    I get an invalid syntax error.

  4. #4
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,940
    Show us your version
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  5. #5
    Summit_IT is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Jan 2019
    Location
    Virginia
    Posts
    47
    I figured it out.
    The form was based on a qry. I used the Expression "Year: Format([DocumentYear],'yyyy')" and this fixed it.

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

Similar Threads

  1. Replies: 1
    Last Post: 06-12-2019, 11:32 PM
  2. Replies: 6
    Last Post: 06-26-2015, 08:55 PM
  3. Replies: 3
    Last Post: 01-03-2014, 03:14 AM
  4. Can access format a date in an odd way? DD-MMM-YYYY
    By redbull in forum Programming
    Replies: 3
    Last Post: 08-23-2013, 11:34 AM
  5. Format options in combined Form field
    By perry in forum Forms
    Replies: 0
    Last Post: 03-06-2009, 04:53 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