Results 1 to 11 of 11
  1. #1
    Join Date
    Mar 2004
    Posts
    35

    Unanswered: Auto Number Generator

    I wrote this code to make a IDNO field. I have a combo box with five optionseach have a different format to a IDNO. But I nedd that all increments, for example: L000001..L000002....L000200...

    P000001..P000200...


    Private Sub System_AfterUpdate()
    Select Case Me.System
    Case "LAN(L)"
    Me.txtIDNo = "L00 "
    Case "PLC(P) *"
    Me.txtIDNo = "P00 "
    Case "SCADA (S) **"
    Me.txtIDNo = "S00 "
    Case "STANDALONE PC'S (Z)"
    Me.txtIDNo = "Z00 "
    Case "VAX (V)"
    Me.txtIDNo = "Z00 "
    Case Else
    MsgBox "Selection error - " & Me.System, vbExclamation
    End Select
    End Sub

  2. #2
    Join Date
    Mar 2004
    Location
    Nashville, TN
    Posts
    557
    I do not see a question. :-/ could you please state what it is that you are asking? (I either didnt see it or I just totally missed it :-P)

    I hope I can help,
    JS
    Have you ever thought about thinking on purpose?

    Jarvis Stubblefield
    Patriot Designs
    Web/Database Development and Consulting
    The-Patriot.net by Patriot Designs

  3. #3
    Join Date
    Mar 2004
    Posts
    35
    Okey, the problem is that when for example I select in the combo box the option LAN, the IDNO=L000001 OR L00182 Depending of the last record in the table. I f I select the option: PLC the IDNO= P000001.....The IDNO is incremental. In my code I make the part L00.. P00.. S00..Z00 BUT I can't make the incremental part in this code. Please help me.

  4. #4
    Join Date
    Mar 2004
    Location
    Nashville, TN
    Posts
    557
    OKay there are several threads about this. I will see if I can find the thread. It just came through here a few days ago so it shouldnt take me long. Please bear with me .

    If you could get the max value from your record source you could put that in a variable and then add 1 to it.

    Yourvariable = yourvariable + 1

    Something like that. I will post soon with the other thread,
    JS
    Have you ever thought about thinking on purpose?

    Jarvis Stubblefield
    Patriot Designs
    Web/Database Development and Consulting
    The-Patriot.net by Patriot Designs

  5. #5
    Join Date
    Mar 2004
    Posts
    35
    I find an example but, when I change the code I can't obtain any result:
    Private Sub System_AfterUpdate()

    Dim lngNextID As Long
    Select Case Me.System
    Case "LAN(L)"
    Me.txtIDNo = "L00 "
    lngNextID = DMax("[IDNo]", "Information") + 1
    Case "PLC(P) *"
    Me.txtIDNo = "P00 "
    lngNextID = DMax("[IDNo]", "Information") + 1
    Case "SCADA (S) **"
    Me.txtIDNo = "S00 "
    lngNextID = DMax("[IDNo]", "Information") + 1
    Case "STANDALONE PC'S (Z)"
    Me.txtIDNo = "Z00 "
    lngNextID = DMax("[IDNo]", "Information") + 1
    Case "VAX (V)"
    Me.txtIDNo = "Z00 "
    lngNextID = DMax("[IDNo]", "Information") + 1
    Case Else
    MsgBox "Selection error - " & Me.System, vbExclamation
    End Select
    End Sub

  6. #6
    Join Date
    Mar 2004
    Location
    Nashville, TN
    Posts
    557
    Okay I do not see in your code where you are assigning that variable to some control like a text box or something. You never know it may be working but you arent telling it to go into a certain text box.

    JS
    Have you ever thought about thinking on purpose?

    Jarvis Stubblefield
    Patriot Designs
    Web/Database Development and Consulting
    The-Patriot.net by Patriot Designs

  7. #7
    Join Date
    Mar 2004
    Posts
    35
    okey, The comco box name is System and the txtIdno is the textbox where the Number that identify each record is write.

  8. #8
    Join Date
    Mar 2004
    Location
    Nashville, TN
    Posts
    557
    You need to set the txtIdno to = lngNextID (is that really supposed to be a long?) I would think that needs to be a string so it has the proper letters in it.

    To set that you would do the following

    Code:
    txtIdno.value = lngNextID
    Of course it is looking like you may need to add lngNextID to the end of a string so as to make the P000001 show up right... so you may need to something like this....

    Code:
    txtIdno.value = "yourstring" & lngNextID
    That way it sticks them both together after you have gotten the highest number. I dont know which way to go just because of the limited information you have provided up to this point.

    JS
    Have you ever thought about thinking on purpose?

    Jarvis Stubblefield
    Patriot Designs
    Web/Database Development and Consulting
    The-Patriot.net by Patriot Designs

  9. #9
    Join Date
    Mar 2004
    Posts
    35
    Private Sub cmbSystem_AfterUpdate()
    Select Case Me.cmbSystem
    Case "LAN(L)"
    Me.txtIDNo.Value = "L00 " & lngNextID
    lngNextID = DMax("[IDNo]", "Information") + 1
    end sub

  10. #10
    Join Date
    Mar 2004
    Location
    Nashville, TN
    Posts
    557
    Does that work for you?

    JS
    Have you ever thought about thinking on purpose?

    Jarvis Stubblefield
    Patriot Designs
    Web/Database Development and Consulting
    The-Patriot.net by Patriot Designs

  11. #11
    Join Date
    Mar 2004
    Posts
    35
    This database is for my work. Why? I try to find a solution and write a example of code. The first code that I insert make the first part: L00 OR P00... but the part of increment I haven't a solution

Posting Permissions

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