Results 1 to 10 of 10
  1. #1
    hemaazez is offline Novice
    Windows 10 Access 2016
    Join Date
    Feb 2017
    Posts
    23

    Thumbs up Auto numbering

    Can you help me please in this problem?
    When I add a new student I need the form write automatically the student number in light of the class reference after choosing the class,


    Can you help me in this code?
    Attached Files Attached Files

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,523
    there already is a field called autonum. Wont this work?

  3. #3
    hemaazez is offline Novice
    Windows 10 Access 2016
    Join Date
    Feb 2017
    Posts
    23

    yes . please

    yes. please . can you do that

    Quote Originally Posted by ranman256 View Post
    there already is a field called autonum. Wont this work?

  4. #4
    ssanfu is offline Master of Nothing
    Windows 7 32bit Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    If I understand correctly, if I add Sam and select student_class = 2, the student_number should be 20002?


    (you misspelled the field name. You have "calss" instead of "class". And you have 2 twice..... missing a "3" in the values.)

    In the after update event of the combo box "student_Class", you would open a query in code selecting the top 1 "class" sorted descending.
    Then you would have to convert the text to a value, add 1, then push the new value into the "student_number" control on the form.

  5. #5
    hemaazez is offline Novice
    Windows 10 Access 2016
    Join Date
    Feb 2017
    Posts
    23

    Thank you Ssanfu for your response

    i corrected the name of fields . when i add a new student i need the form writ the student number in light of the classref from the class table.
    can you please help me in doing that.
    regards



    autoNumber.zip
    Quote Originally Posted by ssanfu View Post
    If I understand correctly, if I add Sam and select student_class = 2, the student_number should be 20002?


    (you misspelled the field name. You have "calss" instead of "class". And you have 2 twice..... missing a "3" in the values.)

    In the after update event of the combo box "student_Class", you would open a query in code selecting the top 1 "class" sorted descending.
    Then you would have to convert the text to a value, add 1, then push the new value into the "student_number" control on the form.

  6. #6
    ssanfu is offline Master of Nothing
    Windows 7 32bit Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    You didn't answer my question about how the numbering should be incremented, so I used my best guess.

    In table "Class", you have the field "Classref" defined as a Text type field. The data in that field looks like this: "650100000". The code will run as long as there is NOT a letter in that string. (Cannot have any thing like "6501C0000" or "65B010000")

    I added a continuous form (Form1) to make it easier for texting.
    The combo box on each form has the same code.
    Attached Files Attached Files

  7. #7
    hemaazez is offline Novice
    Windows 10 Access 2016
    Join Date
    Feb 2017
    Posts
    23
    thank you , and sorry for my late response
    i will tray using it and see the result
    thank you very much
    best regards

  8. #8
    hemaazez is offline Novice
    Windows 10 Access 2016
    Join Date
    Feb 2017
    Posts
    23
    Dear ssanfuClick image for larger version. 

Name:	OrangeWarmheartedCod-size_restricted.gif 
Views:	16 
Size:	162.7 KB 
ID:	37490Click image for larger version. 

Name:	giphy.jpg 
Views:	16 
Size:	153.6 KB 
ID:	37491

  9. #9
    davegri's Avatar
    davegri is offline Excess Access
    Windows 10 Access 2016
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,405
    And he's a jolly good fellow!

  10. #10
    Rainlover's Avatar
    Rainlover is offline Expert
    Windows 7 64bit Access 2003
    Join Date
    Nov 2009
    Location
    Queensland Australia
    Posts
    691
    Have a look at DMax.

    I think it would be more suitable than AutoNumber.

    It may be helpful if you wish to use the same number more than once.

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

Similar Threads

  1. Auto numbering of new records
    By edwardcga in forum Forms
    Replies: 1
    Last Post: 10-20-2013, 04:19 PM
  2. Access Auto Numbering
    By edieb in forum Access
    Replies: 1
    Last Post: 09-25-2013, 11:03 AM
  3. Total Noobie here... question about auto numbering
    By JavaBeans in forum Database Design
    Replies: 10
    Last Post: 04-25-2012, 04:58 PM
  4. Auto numbering of forms
    By bgeorge12 in forum Forms
    Replies: 5
    Last Post: 06-30-2011, 05:05 PM
  5. Auto Numbering
    By rkruczk in forum Forms
    Replies: 0
    Last Post: 10-09-2006, 04:25 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