Results 1 to 4 of 4
  1. #1
    2 Star Lounger
    Join Date
    Nov 2002
    Location
    Mt. Olive, North Carolina, USA
    Posts
    170
    Thanks
    8
    Thanked 0 Times in 0 Posts

    Filling in next number on form (97)

    I have attached a sample db that I am having trouble getting the next number to fill in when I go to the next record. It fills in correctly on the first record when you open up the form but when you go to the next record I get an error stateing that it cannot find the referenced form. Thanks in advance.
    John
    Attached Files Attached Files

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

    Re: Filling in next number on form (97)

    It works OK in the version you attached if I remove the Name and Accounts combo boxes (and set the Required property of Account to No - you stripped down the database too much).

    But I would compute the new number in the Before Insert event of the form, or in the Before Update event (in combination with a check whether you're on a new record):

    Private Sub Form_BeforeInsert(Cancel As Integer)
    Me.Number = Nz(DMax("Number", "St Mary Transactions"), 0) + 1
    End Sub

    See attached mutilated version.
    Attached Files Attached Files

  3. #3
    2 Star Lounger
    Join Date
    Nov 2002
    Location
    Mt. Olive, North Carolina, USA
    Posts
    170
    Thanks
    8
    Thanked 0 Times in 0 Posts

    Re: Filling in next number on form (97)

    Hi Hans,
    I could not get the code to work on the before insert event, all it would fill in was a zero for the number. I put the code in the on current event and it seems to work. I will be using it later tonight. I will let you know if I run into any problems. When I opened up the db you sent, I got a message stating that it was changing some VB code.
    Thanks again.
    John

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

    Re: Filling in next number on form (97)

    I'd clear the Default Value property of the Number field (and of all number and currency fields, for that matter).

    The message you got was probably about references. I had to convert your database to Access 2000 format in order to modify it, then back to Access 97 format.

Posting Permissions

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