none
Help making a new work order number!

    Question

  • I've asked this in an other forum. I'm still new at programing VB. I want to click a button to make a new record and my case# field will be populated with a number like 06-01-0003. I've done this in  Access before by calling another form up that is using hidden textboxes with the day and the number in them. Then combining the  boxes in another box to make the number. Then having the this form copy and paste the number into the first form.  Works ok, just makes for a messy form in design view. I'm now trying to make a VB database app. out of the the Access version. What I would like to do is put code behind a textbox that does this without the other form when you click new record. The number comes from the date 06-01 is year and month, the 0003 is a normal number that I add 1 too each time the new record is pushed. I can't seem to get this to work on VB. Also I want to reset the 0003 back to 0 when the new month starts. Any help would be great and very thankful.

     

    To help: on the form I have 3 boxes one called number  which is the last number then I have a box for current date, then a third called case number where I take the information from the other 2 and use this code:

     

    This is used in hidden box called case number:

    =Format([Dates],"yy") & "-" & Format([Dates],"mm") & "-" & Format([Number],"0000")

    Then I use this behind a button on the form called new case number:

    Private Sub NewCaseNumber_Click()
    Dim intNumber As Variant

       
        intNumber = Me!Number
        DoCmd.GoToRecord , , acNewRec
        Me!Number = intNumber + 1
        [Officer].SetFocus

    End Sub

     

    This takes the last number from the record and adds 1 to it.

    Again any help would be greatly excepted...

    Thursday, January 05, 2006 12:45 PM