Results 1 to 7 of 7
  1. #1
    Join Date
    Aug 2008
    Posts
    9

    Unanswered: access database form

    I have an access database that I'm becoming frustrated by. The table format is
    read_date Black_click Black_total accul
    7/29/08 967752 123275
    7/29/08 967752
    8/29/08 1231231 (1231231 - 967752) new entry
    this is the basis of the table, I always have a form where the user inputs
    read_date
    black_click
    black_total (this field I want to have popluated by black_click - accul (of the last month)
    how can i get this formula into the form using the inforamtion from the previous record.

    Thanks
    PAm

  2. #2
    Join Date
    Apr 2004
    Location
    metro Detroit
    Posts
    634
    A few questions:

    What are the names of the controls on the form for read_date, black_click, and black_total?

    Is the read_date from last month the same for all black_click or are there different dates for diferent black_click?

    Is there ever more than one read_date for a black_click in a month?

    What the heck is a black_click?

  3. #3
    Join Date
    Aug 2008
    Posts
    9

    reply

    1. The control names fro read_date, Black_click and black_total are the same names as the label

    2. differnet dates for the same black click

    3. no only one read_date

    4. black_click is only the name I gave to the label because the user inputs the number of clicks on a black ink printer in only to get paid.

    Quote Originally Posted by rogue
    A few questions:

    What are the names of the controls on the form for read_date, black_click, and black_total?

    Is the read_date from last month the same for all black_click or are there different dates for diferent black_click?

    Is there ever more than one read_date for a black_click in a month?

    What the heck is a black_click?

  4. #4
    Join Date
    Nov 2007
    Location
    Adelaide, South Australia
    Posts
    4,049
    You might want to look at DLast(). Your form can look up fields of the last record with it.
    Owner and Manager of
    CypherBYTE, Microsoft Access Development Specialists.
    Microsoft Access MCP.
    And all around nice guy!


    "Heck it's something understood by accountants ... so it can't be 'that' difficult..." -- Healdem
    "...teach a man to code and he'll be frustrated for life! " -- georgev

  5. #5
    Join Date
    Aug 2008
    Posts
    9
    Thank you for the suggestion of Dlast. Below is the VB coding that I have aready which works great. What this does is put the Black_Click amount in the black_total field on the form which i want, but now I need to take the last record of a field called accul and subtract the recently entered black_click amount and then put it into the black_total. I guess I'm confused on where to put the Dlast command and also keep this coding.

    Me!Black_Total = Me!Black_Click - Nz(DLookup("[Black_Click]", _
    "[1050 -1-695CB]", _
    "[Read_Date] = #" & DMax("[Read_Date]", "[1050 -1-695CB]") & "#"))



    Quote Originally Posted by StarTrekker
    You might want to look at DLast(). Your form can look up fields of the last record with it.

  6. #6
    Join Date
    Nov 2007
    Location
    Adelaide, South Australia
    Posts
    4,049
    Where to put code depends on timing... it usually comes down to WHEN. When do you want the DLast to run? ... on clicking a command button or after entering a certain field or perhaps after your above calculation. This will determine where to put the code.

    The code would be something like:

    Me.Black_Total = DLast("Accul", "[1050 -1-695CB]") - Me.Black_Click

    But I am guessing as to some specifics here though.
    Last edited by StarTrekker; 08-25-08 at 00:21.
    Owner and Manager of
    CypherBYTE, Microsoft Access Development Specialists.
    Microsoft Access MCP.
    And all around nice guy!


    "Heck it's something understood by accountants ... so it can't be 'that' difficult..." -- Healdem
    "...teach a man to code and he'll be frustrated for life! " -- georgev

  7. #7
    Join Date
    Jun 2005
    Location
    Richmond, Virginia USA
    Posts
    2,763
    Provided Answers: 19
    DLast() is one of those Access functions whose names belies what it actually does!

    Quote Originally Posted by Access Help
    You can use the DFirst and DLast functions to return a random record from a particular field in a table or query when you simply need any value from that field.
    Somewhere along the way, realizing that the function doesn't do what any halfway intelligent person would assume it does, the Access Gnomes decided to include instructions on how to find the last or first value for a field. Go into the code window for any form, call up Help and enter DLast and it'll take you there.
    Hope this helps!

    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

Posting Permissions

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