1. Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members.

Access 2007 Increase Incident# by 1 in field on form

Discussion in 'Business Applications' started by elancour, Aug 16, 2011.

Thread Status:
Not open for further replies.
  1. elancour

    elancour Thread Starter

    Joined:
    Apr 12, 2011
    Messages:
    10
    Hi,

    I am looking for some help on my code to lookup the largest incident # then add 1 to it when a new form is selected. I created a new record button on my form but would also like to have the new incident number populate when the new record comes up.

    What I have is
    Private Sub cmdnew_Click()
    If Me.New Record Then
    Me.Incident# (not really sure if I should put the field name here or not?) =Nz(DMax(Incident#, External_Theft),0)+1
    End If
    End Sub

    Any help is greatly appreciated.

    The field name is Incident# and the Table name is External_Theft
    Erica
     
  2. Rockn

    Rockn

    Joined:
    Jul 29, 2001
    Messages:
    21,334
    You may want to consider changing the name of your field since the # is used for dates in certain instances.

    You could create a query to do Max(Incident#)+1 and then call that query from your forms onLoad event handler to populate the field you want with that number.
     
  3. elancour

    elancour Thread Starter

    Joined:
    Apr 12, 2011
    Messages:
    10
    Thank you I did go and change the field name to Case Number. I will try the query suggestion. Thank you!
     
As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 733,556 other people just like you!

Loading...
Thread Status:
Not open for further replies.

Short URL to this thread: https://techguy.org/1012826

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice