+ Reply to Thread
Results 1 to 4 of 4

code to create unique alphanumeric form number every time form is opened

  1. #1
    Registered User
    Join Date
    08-06-2014
    Location
    Pune, India
    MS-Off Ver
    2010
    Posts
    84

    code to create unique alphanumeric form number every time form is opened

    Hi All,
    I have created vba based user form. Form opens by command button click placed in same excel sheet. I have created text box in form in which I want alphanumeric form ID to be displayed such as "DRLL-0001". Once the form is closed and opened again, next number should be displayed in same text box that is "DRLL-0002".
    I want unique Form ID so that I can retrive data back to form based on this ID from database.

    Thanks in Advance.

  2. #2
    Forum Expert Tinbendr's Avatar
    Join Date
    06-26-2012
    Location
    USA
    MS-Off Ver
    Office 2010
    Posts
    2,125

    Re: code to create unique alphanumeric form number every time form is opened

    I use the built-in document properties to store the 'invoice' number in, say, the author field. When you close the form, store the number in the author field. When you open the userform, in the Initialize event, fetch the number, split it, add one to the right hand part, and put it back together on the form.

    The reason I use the author field is that it's easily accessible if it gets screwed up.

    I use a label, too, instead of a textbox to prevent tampering.
    David
    (*) Reputation points appreciated.

  3. #3
    Registered User
    Join Date
    08-06-2014
    Location
    Pune, India
    MS-Off Ver
    2010
    Posts
    84

    Re: code to create unique alphanumeric form number every time form is opened

    Hi Tinbendr,
    Sorry but I am not that familiar with VBA. If you dont mind, can you please illustrate with an example.
    Thanks in Advance.

  4. #4
    Forum Expert Tinbendr's Avatar
    Join Date
    06-26-2012
    Location
    USA
    MS-Off Ver
    Office 2010
    Posts
    2,125

    Re: code to create unique alphanumeric form number every time form is opened

    If you can upload a sample file, I'll be glad to.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Run code each time form is opened
    By brandonboucher in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 07-01-2014, 02:11 PM
  2. Replies: 1
    Last Post: 01-17-2014, 05:30 PM
  3. Form: Create a caption that equals the next number in a list of unique IDs
    By James B in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-21-2011, 09:15 AM
  4. [SOLVED] How can I generate a unique number each time a form is printed?
    By homaxlinda in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 08-17-2006, 04:55 PM
  5. [SOLVED] how can I make a form number change everytime the form is opened
    By babydumplingspita in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 10-10-2005, 03:05 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1