Results 1 to 4 of 4
  1. #1
    jaytejani is offline Novice
    Windows 7 64bit Access 2013
    Join Date
    Sep 2014
    Posts
    2

    auto-number for multi criteria or

    hi all

    i m quite fresh in access, i have form that i want auto number for different value or criteria

    my table is like that with some sample data

    Voucher_no | Voucher_type |
    1 | Receipt
    2 Receipt
    3 Receipt
    1 Payment


    2 Payment
    1 Journal
    2 Journal


    i want Voucher_no as Auto number for different Voucher_type

    is that possible if so, then how????

  2. #2
    John_G is offline VIP
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2011
    Location
    Ottawa, ON (area)
    Posts
    2,615
    You can generate the Voucher_No automatically, but you cannot use Autonumber type. You would have to use a small bit of VBA code to do it.

    Basically, you would look at the voucher_type, find the maximum currently existing Voucher_no, and add 1 to it.

    This is an example of what you might do:

    NextNumber = nz(dmax("Voucher_No","YourTableName","Voucher_type = '" & VoucherType & "'"),0) + 1
    names in italics represent names in your own database.

    I ses Nz to handle the case where the new voucher type isn't in the table yet - you would get an error otherwise.

    John

  3. #3
    jaytejani is offline Novice
    Windows 7 64bit Access 2013
    Join Date
    Sep 2014
    Posts
    2
    Thanks buddy for replay
    one more favor can u do where should i put this code, i mean in which property

  4. #4
    John_G is offline VIP
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2011
    Location
    Ottawa, ON (area)
    Posts
    2,615
    If you are the only user of the database, you could put the code in the After Update event of the Voucher Type. The code will run every time you type or select a value in the Voucher_Type field, so the Voucher No. could change if you change the voucher type.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Auto multi-level position numbering!!!!
    By joe55555 in forum Access
    Replies: 4
    Last Post: 11-04-2013, 02:14 AM
  2. Auto number automatically next number
    By wnicole in forum Access
    Replies: 3
    Last Post: 10-17-2013, 08:45 AM
  3. How do I return a value on multi criteria?
    By smc678 in forum Access
    Replies: 5
    Last Post: 11-20-2012, 02:35 PM
  4. Replies: 5
    Last Post: 08-02-2012, 09:44 AM
  5. Multi Criteria Query
    By hawkins in forum Queries
    Replies: 1
    Last Post: 07-18-2011, 01:44 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums