Results 1 to 6 of 6
  1. #1
    3 Star Lounger
    Join Date
    Dec 2001
    Location
    Maine, USA
    Posts
    258
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Total from subform on main form (2000)

    OK. This has got to be something simple, but I've tried everything I can think of or find in my books or sample DBs for the last three evenings and can't get it. I'm used to databases that keep track of people - this one keeps track of money.

    I have a subform. It is linked to the main form by TransactionID. All I want is a field (TransTotal - unbound) on the main form (F_Transactions) that will display the total of the amounts (DetAmount) from the subform (F_TransactionDetailsSub) for that transaction. Seems like it should be simple - but I'm completely stumped. At one point I had it so it almost worked - but it was always one entry behind the subform. That was several experiments ago, and I'm completely back to square one now.

    Can someone point me in the right direction or refer me to something that will explain how to do this?

    -cynthia

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Total from subform on main form (2000)

    Place a text box in the footer of the subform with Control Source =Sum([DetAmount]). This will display the sum of the amounts for the records in the subform.

    If you prefer to display the sum in the main form, you still need the text box in the footer of the subform; let's say you named it txtSumOfDetAmount. You can hide it by setting its Visible property to No.
    In the main form, place another text box with Control Source =[F_TransactionDetailsSub].[Form]![txtSumOfDetAmount]
    Here, you must use the name of the subform as a control on the main form; this is not necessarily the same as the name of the subform in the database window.

  3. #3
    3 Star Lounger
    Join Date
    Dec 2001
    Location
    Maine, USA
    Posts
    258
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Total from subform on main form (2000)

    Thanks Hans,
    I had tried nearly what you suggest, and just to be sure I moved the field on the subform from the header (where I had it) to the footer, and I renamed it to match the name you used in your post so I could cut and paste from the post and eliminate the possibility of a typo. At one point I was getting a number in the txt field on the subform (before I renamed it), but now all I'm getting is #name in both of them (subform and main form). I am beginning to suspect that the database may be corrupted because when I tried to zip it to post for you to look at, I had problems with that too! Fortunately there is not much to this database yet, so I'm going to start it from scratch this weekend. If it still doesn't work, I will post again.

    One question. Last night in some miscellaneous reading on the boards, I found and downloaded some tips for databases that someone had made for their students. One tip was "Never run your database from your A: drive". I have been running this database off a zip disk. Is this bad practice and could it cause corruption?

    Thanks,
    -cynthia

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Total from subform on main form (2000)

    Cynthia,

    If you suspect corruption, you can try
    <UL><LI>Compact and Repair (in Tools/Database Utilities).
    <LI>Decompile - do a search for decompile in this forum if you don't know what that is.
    <LI>Create a new blank database and import all database objects from the suspect database.[/list]Good luck!

    The rationale behind the warning about the A: drive (probably from <!profile=SteveH>SteveH<!/profile>'s Golden Access Rules) is that Access (like many programs) needs a certain amount of free disk space to function correctly. On a 1.44 MB floppy disk, you run into problems quite soon; a Zip disk has a much larger capacity, so provided it is not almost full, you should be OK. For best performance, however, I recommend copying the database to hard disk, and work from there.

  5. #5
    3 Star Lounger
    Join Date
    Dec 2001
    Location
    Maine, USA
    Posts
    258
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Total from subform on main form (2000)

    Thank you for the explanation about running from disk.

    I had already both compacted and created a new empty database and imported objects, but I need to learn about the decompiling, so will do that this weekend as well. And I'll keep my fingers crossed! At this point I've got significantly more time into this particular project than its worth, but I can't stand to be stumped by something this simple.

    -cynthia

  6. #6
    3 Star Lounger
    Join Date
    Dec 2001
    Location
    Maine, USA
    Posts
    258
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Total from subform on main form (2000)

    It works now! The part I was originally missing was the part you supplied to put as the datasource in the field on the mainform. The reason it didn't work when I followed your instructions was that in my blearyness of having tried so many things so many times, somewhere in there I had deleted the = from in front of the Sum on the subform <img src=/S/blush.gif border=0 alt=blush width=15 height=15> . Thanks for your help. It's now working as I wanted it to - and now I know about not running it from disk!

    -cynthia

Posting Permissions

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