Results 1 to 8 of 8
  1. #1
    Join Date
    Aug 2009
    Posts
    7

    Unanswered: 2 problems from a novice

    Hi,

    greetings from Portugal

    So, I have two problems that I've been scratching my head for a lonh time to solve but still couldn't.

    The first one is this:

    I use one of my tables to keep records off stuff bought by the company. Therefore I have a field called "Price". In a querie I am able to see the total price of everything bought by using the "Totals" button. My question is, how can I assign this total price value to a variable so that I can dispay it in a form?

    An the second one is:

    I've got a form to add an item to the above mentioned table. To record it to te table I used the Button Wizard like so: Record Operations-->Add New Record. The problem is that when I open this form, it already cames with a pre-loaded record taken from my table (don't know why - I wish it came blank) and when I use the said button, instead of adding a new record it instead replaces the pre-loaded record for the new one.

    Any help would be apreciated
    Last edited by franchico; 08-05-09 at 12:17.

  2. #2
    Join Date
    Mar 2003
    Location
    The Bottom of The Barrel
    Posts
    6,102
    Provided Answers: 1
    Quote Originally Posted by franchico
    greetings from Portugal
    Well hello! How's the food over there?

    I use one of my tables to keep records off stuff bought by the company. Therefore I have a field called "Price". In a querie I am able to see the total price of everything bought by using the "Totals" button. My question is, how can I assign this total price value to a variable so that I can dispay it in a form?
    What do you mean "assign to a variable"? If you have an aggregate query then you can define the field name by using:

    FieldNameGoesHere: SUM(whatever)

    or in SQL

    SELECT ... , SUM(whatever) As FieldNameGoesHere

    If you meant you want to calculate the sum on the fly in a form, maybe DSum() is what you're looking for...

    I've got a form to add an item to the above mentioned table. To record it to te table I used the Button Wizard like so: Record Operations-->Add New Record. The problem is that when I open this form, it already cames with a pre-loaded record taken from my table
    Try setting the Data Entry property for you form to true.
    oh yeah... documentation... I have heard of that.

    *** What Do You Want In The MS Access Forum? ***

  3. #3
    Join Date
    Aug 2009
    Posts
    7
    Hi,

    the food is mostly fish and seafood, as we were originally a country of seamen and nautic explorers

    Regarding the second problem, setting the Data Entry property to true sovled it, so thanks a bunch.

    As for the first one, I had a professor last semester in colege that used to say "If people can't understand what you're saying then draw it for them". Well, I tried to upload a print screen but aparently that is not possible. So, i'll try to draw it as best as I can.


    DataSheet View:


    MATERIAL PRICE
    materialA 10$
    materialB 25$
    materialC 5$
    TOTAL 40$

    What I would like to do is to save the "40$" in some kind of variable that I can display in a form and also record it in a table.

    I apologise if the names are badly translated (my access 2007 version is in Portuguese)


    By the way, I in fact have a 3rd question:

    I have a table with three fields. How can I make the 3rd filed be the sum of fields one plus two? Example:

    FieldA FieldB FieldC
    1 4 5
    2 2 4
    3 7 10

    I tried using a querie an inputing FiledC: [FieldA] + [FieldB] in the expression. By doing so, the querie displays FieldC as beeing the sum of the other two but it doesn't save it in the table (which is what I wanted for it to do in the first place).
    Last edited by franchico; 08-05-09 at 14:38.

  4. #4
    Join Date
    Mar 2003
    Location
    The Bottom of The Barrel
    Posts
    6,102
    Provided Answers: 1
    Why do you want to save it in the table itself? Do you have a requirement to persist a snapshot of that data because it might change later?

    Generally best practices say you should default to never storing derived data unless you NEED to. You'll receive almost no performance gain in simple operations like yours while introducing a GREATLY expanded margin of error to your overall application.
    oh yeah... documentation... I have heard of that.

    *** What Do You Want In The MS Access Forum? ***

  5. #5
    Join Date
    Aug 2009
    Posts
    7
    Ok. Thanks a lot Monkey

  6. #6
    Join Date
    Nov 2007
    Location
    Adelaide, South Australia
    Posts
    4,049
    You're welcome!

    Oh, Access Monkey, not L33t Helpa Munky
    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
    Aug 2009
    Posts
    7
    I meat thanks Teddy

  8. #8
    Join Date
    Nov 2007
    Location
    Adelaide, South Australia
    Posts
    4,049
    Where would we be without our Teddy?!
    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

Posting Permissions

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