Results 1 to 2 of 2
  1. #1
    Vethra is offline Novice
    Windows 7 64bit Access 2013
    Join Date
    Jun 2015
    Posts
    10

    Auto Number with Date

    Good morning everyone,



    Just wondering how I can create a auto generating number with today's date in it.

    Here is an example.

    I want textbox1 in my form to have a automatically generated ID.

    (yymmdd-00)
    150722-01
    150722-02
    150722-03
    150722-04
    and so on.... for each new report.

    Is it possible to do this through my ID in my table?

    Thanks,
    Dilan

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,550
    you dont need to, autonumber creates a value with NO code.

    Tho for your method, you would have to FORCE users to enter data from a form but NOT directly into the table. You'd need an 'entry' table, to verify the counter.
    The form can get the date easy, but when the user clicks SAVE, it must ping the table for the current count, add 1, then build the key to be saved, then append the saved data.
    Code:
    private btnSave_Click()
       dim vDate, vKey
       dim iNum as integer
    
      vDate  =format( Date(),"yymmdd")
      vKey= dMax("[Key],"table", vDate)
      inum = mid(vKey, instrrev(vKey,"-")+1)
      txtKey = vDate &  & format(iNum + 1,"00")
       
      docmd.openquery "qaPostData2Tbl"
    end sub
    again , lots of code that can break, when you only need autonum to do the job code free.

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

Similar Threads

  1. Replies: 5
    Last Post: 11-30-2014, 12:46 PM
  2. Replies: 1
    Last Post: 10-25-2013, 03:38 PM
  3. Auto number automatically next number
    By wnicole in forum Access
    Replies: 3
    Last Post: 10-17-2013, 08:45 AM
  4. Auto Number
    By sah in forum Forms
    Replies: 1
    Last Post: 04-30-2012, 07:20 AM
  5. Auto-number
    By rkski in forum Programming
    Replies: 2
    Last Post: 01-13-2010, 02:04 AM

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