Results 1 to 4 of 4
  1. #1
    c0crut01 is offline Novice
    Windows 10 Access 2016
    Join Date
    Jun 2019
    Posts
    1

    Question How to format a textbox to have a year within its string.

    I know you can create a textbox that automatically shows the date and time. However, my boss wants to be able to have the current year within the Permit Number. Attached is a picture of what he wants. Each Permit Number starts with the static letters "EP" followed by the current year (in this case 2019) followed by the auto generated permit number. I need a way to format this in the property sheet so that when 2020 comes along, the 2019 will automatically change to 2020.

    Any help is appreciated.

    Click image for larger version. 

Name:	How to.PNG 
Views:	16 
Size:	102.6 KB 
ID:	38681

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    Generating custom unique identifier is a common topic. Start with https://www.accessforums.net/showthread.php?t=23329
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    orange's Avatar
    orange is offline Moderator
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,726
    Further to June's advice, there is a difference between data storage and data presentation.

    Data should be "atomic". That means that data should be stored in its most basic, indivisible
    form; for example, avoid storing a name as a single data element, with first name,
    middle name, Lastname. Each of these are separate pieces of data and should be stored in separate columns.

    For presentation, you can concatenate values to customize the display eg. John G. Smith.
    Or as in your example Pmt-2019-0221-X or whatever you want to present.

  4. #4
    Join Date
    Apr 2017
    Posts
    1,680
    I found an older thread with similar question (https://www.accessforums.net/showthread.php?t=65653). When you really want to go with custom ID, I posted there an answer, where I described the calculation of ID in format CCYYYYMMDDnnn I use in one of my databases.

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

Similar Threads

  1. Replies: 3
    Last Post: 02-01-2018, 03:10 AM
  2. Format Concatenated String
    By JimO in forum Access
    Replies: 3
    Last Post: 05-17-2016, 04:32 PM
  3. Referencing a textbox using a string in VBA
    By Markb384 in forum Programming
    Replies: 3
    Last Post: 01-24-2014, 09:43 AM
  4. Concat textbox name with string
    By dwif in forum Access
    Replies: 2
    Last Post: 06-08-2013, 02:31 PM
  5. Format within a string
    By wdrspens in forum Reports
    Replies: 1
    Last Post: 04-16-2011, 05:51 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