Auto increment student number

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • DhireLouchoulle
    New Member
    • Feb 2013
    • 1

    Auto increment student number

    I want to create a code that can create a auto increment number of student. start with the year enroll like
    2013-100-001
    2013-100-002

    which is the best codes fit, but I don't know how to do it. Please help.I try to search code in internet and try to run it in my p.c but nothing works.

    Thanks in advanced for any input!
  • Rabbit
    Recognized Expert MVP
    • Jan 2007
    • 12517

    #2
    Is this a Microsoft Access question? Because if it is you are in the wrong forum and I can move it for you.

    Comment

    • lightroses
      New Member
      • Feb 2013
      • 16

      #3
      this is a Visual basic question. I'm sorry for my not clear explanation. I mean in the textbox of vb6 every time the user input a new student the number will increment the format I want to be is the year-sem-incrementation:
      2013-100-001
      and when the user click the save button it all saved in ms access. I use the auto increment number as the unique identity number of a student.

      Comment

      • CabaasSalwe
        New Member
        • Jan 2013
        • 4

        #4
        Try this.

        Code:
        Dim sql as string
        ------------------- your Connection
        Sql="Select Count(STDID) as ID from STUDENTTable"
        dim cmd as Sqlcommand
        cmd.connection= your Connection
        cmd.commandtype=commandText
        cmd.commandtext=SQL
        Dim RDR as SQlDatareader
        RDR=cmd.executeRearder
        If RDR.read then
        Label1.text=RDR.Items("ID")+1
        end if

        Comment

        • lightroses
          New Member
          • Feb 2013
          • 16

          #5
          Hello CabaasSalwe thank you for your reply. I try to run this code in my vb6 and I will tell you later what happen! Thanks a Lot again

          Comment

          • lightroses
            New Member
            • Feb 2013
            • 16

            #6
            ahm I try to run your given code. I have a question where I Can put this general codes? into the form or module.
            Code:
            Dim sql As String
            
            Tsql = "Select Count(ID) as ID from Tbl_Tithes"
            
            Dim cmd As Sqlcommand
            cmd.Connection = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\TithesDB.mdb" & ";Persist Security Info=False"
            cmd.commandtype = commandtext
            cmd.commandtext = sql
            Dim RDR As SQlDatareader
            RDR = cmd.executeRearder
            If RDR.read Then
            Label1.Text = RDR.Items("ID") + 1
            End If

            Comment

            • Rabbit
              Recognized Expert MVP
              • Jan 2007
              • 12517

              #7
              lightrose, I can't tell if you created a new account to ask this question or if you're just hijacking this thread because you are not the original poster. Unless I get clarification, I will have to delete these posts as they may not relate to the actual poster's situation.

              Comment

              • lightroses
                New Member
                • Feb 2013
                • 16

                #8
                I'm sorry I have no intention to hijack this thread I am not a kind of person. Don't worry I will never use dhirelouchoulle account.

                Comment

                • Killer42
                  Recognized Expert Expert
                  • Oct 2006
                  • 8429

                  #9
                  It might help to tell us what version of Access you're using, as the capabilities of things like autonumber or calculated fields tend to change over time.

                  Comment

                  Working...