Results 1 to 5 of 5
  1. #1
    5 Star Lounger bfxtrfcmgr's Avatar
    Join Date
    Aug 2002
    Location
    Fresno, California, USA
    Posts
    995
    Thanks
    12
    Thanked 0 Times in 0 Posts

    Faux AutoNumber (2003)

    In the attached sample I "stole" the code for the After Update event of frmOrder_New from another db I have been running for quite some time. It works just fine in that db, but it doesn't do anything in this one. Am I maybe missing a reference or something? I can't use a regular AutoNumber because this is for invoice numbers beginning at five digits. As usual, any help is much appreciated.
    Bryan,
    Not the smartest critter on the glacier. . .
    . . .but I'm persistent (does that count?)

  2. #2
    Super Moderator
    Join Date
    Jun 2002
    Location
    Mt Macedon, Victoria, Australia
    Posts
    3,993
    Thanks
    1
    Thanked 45 Times in 44 Posts

    Re: Faux AutoNumber (2003)

    The db you posted does not have a frmOrder_New , just a form frmOrderDetail. This does not have any code in an after update event that I can see.
    Regards
    John



  3. #3
    5 Star Lounger bfxtrfcmgr's Avatar
    Join Date
    Aug 2002
    Location
    Fresno, California, USA
    Posts
    995
    Thanks
    12
    Thanked 0 Times in 0 Posts

    Re: Faux AutoNumber (2003)

    Ooops; too many samples in that folder <img src=/S/crazy.gif border=0 alt=crazy width=15 height=15>
    Bryan,
    Not the smartest critter on the glacier. . .
    . . .but I'm persistent (does that count?)

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Faux AutoNumber (2003)

    The code should be in the Before Update event instead of in the After Update event. And I suppose that you only want to assign a new number in a new record, not in an existing record. Here is a midified version:

    Private Sub Form_BeforeUpdate(Cancel As Integer)
    Dim dbs As DAO.Database, rs As DAO.Recordset
    Dim lngProNo As Long
    If Not Me.NewRecord Then Exit Sub
    Set dbs = CurrentDb
    Set rs = dbs.OpenRecordset("tblProNoControl", dbOpenDynaset)
    rs.Edit
    rs!NextAvailableProNo = rs!NextAvailableProNo + 1
    lngProNo = rs!NextAvailableProNo
    rs.Update
    Me.ProNo = lngProNo
    Set rs = Nothing
    Set dbs = Nothing
    End Sub

  5. #5
    5 Star Lounger bfxtrfcmgr's Avatar
    Join Date
    Aug 2002
    Location
    Fresno, California, USA
    Posts
    995
    Thanks
    12
    Thanked 0 Times in 0 Posts

    Re: Faux AutoNumber (2003)

    <img src=/S/brickwall.gif border=0 alt=brickwall width=25 height=15> Sometimes I wonder how I even manage to sharpen a pencil. Works much better in the Before Update event <img src=/S/doh.gif border=0 alt=doh width=15 height=15>!
    Thanks for the modification also, now I can add a new record from frmOrder_Detail as well as frmOrder_New.

    Many thanks!
    Bryan,
    Not the smartest critter on the glacier. . .
    . . .but I'm persistent (does that count?)

Posting Permissions

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