Results 1 to 2 of 2
  1. #1
    kutehart is offline Novice
    Windows XP Access 2007
    Join Date
    Aug 2010
    Posts
    1

    Question Autonumbering when a checkbox is clicked?

    Hi there. Hoping someone can help.



    I've created a form that I would like to essentially become a customer receipt when certain criteria is met. I'd like, when I click on the "Paid" button, for a Receipt # to be automatically generated and displayed on the form. Is there a way to do this?

  2. #2
    jzwp11 is offline VIP
    Windows 7 Access 2007
    Join Date
    Jun 2010
    Location
    Dayton, OH
    Posts
    2,901
    You should be able to do it. In the on click event of the Paid button, you will want to increment the last receipt number by 1 and assign that to the textbox control that holds the receipt number. If you do not have any previous receipt numbers, you will need to check and assign the first one. The code would look something like the following. The DCount() function is used to check to see if any receipt numbers already exist, if not 1 is assigned to the receipt number control (me.longReceiptNo). If receipt numbers already exist, the DMax() function finds the last (greatest receipt number) generated and adds 1 to it and then assigns it to the control.

    Code:
    If DCount("*", "tblPayments","longReceiptNo<>0") = 0 Then
        Me.longReceiptNo = 1
    Else
        Me.longReceiptNo = DMax("longReceiptNo", "tblPayments") + 1
    End If
    You'll have to substitute your own table/field names
    Last edited by jzwp11; 08-02-2010 at 12:30 PM.

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

Similar Threads

  1. How to pass what was clicked to module?
    By nichojo in forum Modules
    Replies: 11
    Last Post: 07-22-2010, 08:27 AM
  2. Replies: 6
    Last Post: 04-23-2010, 06:43 AM
  3. Replies: 1
    Last Post: 01-29-2010, 11:30 AM
  4. Replies: 6
    Last Post: 09-26-2009, 07:17 AM
  5. checkbox
    By Suresh in forum Forms
    Replies: 0
    Last Post: 12-19-2007, 01:30 AM

Tags for this Thread

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