Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

increment a column value automatically

ukinusaukinusa Member Posts: 7
how do i automatically increment a column's value in a form? that is if i add a new record, one of the columns should have it's value incremented by one. i dont want to use the autonumber field because of the problems it gives later on. i am sure there's an alternative code that can be incorporated in the form. i posted this here a few weeks back but got no where. so i am posting it agai.
thanks for all your help!
uk.

Comments

  • compuchipcompuchip Member Posts: 273
    : how do i automatically increment a column's value in a form? that is if i add a new record, one of the columns should have it's value incremented by one. i dont want to use the autonumber field because of the problems it gives later on. i am sure there's an alternative code that can be incorporated in the form. i posted this here a few weeks back but got no where. so i am posting it agai.
    : thanks for all your help!
    : uk.
    :

    You can use VB code to do this.
    You make a query that gets the MAX() of the field you want to increment and use VB to open this Recordset.
    Then all you have to do is add one to it
    Example:
    Your query "MaxID" is like this:
    SELECT Max(ID) FROM YourTable
    [code]
    Function GiveID()
    Dim rst as Recordset
    Set rst = CurrentDB.OpenRecordset("MaxID")
    GiveID = rst.Fields(0) + 1
    rst.Close
    End Sub
    [/code]
  • Shawn CarterShawn Carter Member Posts: 0

    ________ { http://forcoder.org } free video tutorials and ebooks about // C MATLAB Python Assembly Objective-C PL/SQL Perl PHP R Swift C# Ruby Delphi Visual Basic .NET Scratch C++ Go JavaScript Java Visual Basic Julia Crystal Lisp F# Apex Dart Prolog LabVIEW Hack ABAP COBOL Erlang Lua Fortran Kotlin Alice SAS Rust Ada Transact-SQL D FoxPro Bash Scala ML Clojure Scheme VBScript Awk Logo // ________

Sign In or Register to comment.