Results 1 to 3 of 3

Thread: How to code Autoincrement using Access

  1. #1

    Thread Starter
    New Member
    Join Date
    Dec 2000
    Location
    Madurai
    Posts
    2

    Question

    Hi

    i want set autoincremwnt in product code . how to code using access. pls mail me


    nagarajan

  2. #2
    PowerPoster Lethal's Avatar
    Join Date
    Oct 2000
    Location
    Ohio
    Posts
    2,496

    Talking .

    When you design your access table, set the Fields data type to autonumber

  3. #3
    Guest

    Solution for AutoIncrement

    Originally posted by naga_nr
    Hi

    i want set autoincremwnt in product code . how to code using access. pls mail me


    nagarajan
    Step wise Solution :
    1. While opening recordset use the max property with the field to retrieve the maximum value record. for ex:

    rs.Open "Select max(ProdCode) from Product", cn, adOpenKeyset, adLockOptimistic

    txtCode.Text = rs(0).Value

    2. On Button Click write this code :
    Dim iPos As Integer
    Dim iCnt As Integer

    iPos = InStr(1, txtCode.Text, "R")
    iCnt = Mid(txtCode.Text, iPos + 1)

    iCnt = iCnt + 1

    txtCode.Text = "PR" & iCnt

    On each click u will get increment in the value

    Check if it works ,,

    Bye
    Ajit Rajput
    [email protected]
    Pune

Posting Permissions

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



Click Here to Expand Forum to Full Width