+ Reply to Thread
Results 1 to 13 of 13

adding consecutive number to userform textbox

  1. #1
    Forum Contributor
    Join Date
    01-28-2007
    MS-Off Ver
    2019
    Posts
    204

    adding consecutive number to userform textbox

    i've got a sample database (attached) with a userform for inputting of data. What i want it to do is automatically generate the next number and add it to textbox "our ref" on the userform. the number is in Col C. This is the code i've tried using the code highlighted in red which doesnt work..... can you point me in the right direction ?

    i've attached said file...

    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by royUK; 04-10-2008 at 08:53 AM.

  2. #2
    Forum Expert
    Join Date
    01-15-2007
    Location
    Brisbane, Australia
    MS-Off Ver
    2007
    Posts
    6,591
    Hi

    Try

    Please Login or Register  to view this content.

    rylo

  3. #3
    Forum Contributor
    Join Date
    01-28-2007
    MS-Off Ver
    2019
    Posts
    204
    that gives me a number but it doesnt give me the next consecutive number

  4. #4
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    You don't need all those Loops nor Selections. Change the initialize code to

    Please Login or Register  to view this content.
    Please don't use colours and large font in your code as above it is not helping us read it!

    A TextBox does not have an additem method.

    Search the Forum for some examples of userforms or look at the databaseform example here

    http://www.excel-it.com/vba_examples.htm
    Last edited by royUK; 04-10-2008 at 06:36 AM.
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  5. #5
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    I think this is what you are trying to do

    Please Login or Register  to view this content.
    Just my opinion but I would definitely lose the greenn background of the userform

  6. #6
    Forum Contributor
    Join Date
    01-28-2007
    MS-Off Ver
    2019
    Posts
    204
    This is only giving me 1 where as the last number in col c is 8 so i would want it to give me the next number which would be 9 and the next time a sample is entered it would be 10 and so on.



    point taken on the green........ now you mention it it does look in your face.

  7. #7
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    Make sure that your cells are formatted as number.

  8. #8
    Forum Contributor
    Join Date
    01-28-2007
    MS-Off Ver
    2019
    Posts
    204
    they were formated as general but changed them to number but it's still giving me the number as 1

  9. #9
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    Not in the example workbook that I downloaded, I get 9
    Attached Files Attached Files
    Last edited by royUK; 04-10-2008 at 07:55 AM.

  10. #10
    Forum Contributor
    Join Date
    01-28-2007
    MS-Off Ver
    2019
    Posts
    204
    i'm lost i've tried changine the formatting the type in my own sample i'm lost.
    this is the code for the whole userform that i'm using. i cut and paste your code over the old code for textbox3. which is at the very bottom.
    Please Login or Register  to view this content.

  11. #11
    Forum Contributor
    Join Date
    01-28-2007
    MS-Off Ver
    2019
    Posts
    204
    i download the version you edited and that works but when i copy the same code onto my version it doesnt work ? The actual file is 500kb.

  12. #12
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    Your original numbers in Column C do not appear to be recognised as numbers, I had to type them in again.

  13. #13
    Forum Contributor
    Join Date
    01-28-2007
    MS-Off Ver
    2019
    Posts
    204
    bingo !Obvious really i suppose. yet again this forum saves the day. thanks

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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