Results 1 to 7 of 7
  1. #1
    ETCallHome is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    Mar 2011
    Location
    Limpopo, South Africa
    Posts
    48

    Continuous Form - Calculaing a Value

    Hi,

    I tried searching the internet and tried a few examples, but still cannot get it working. Here is my problem! I have a continuous form that displays Tbl.fldA, Tbl.fldB, Tbl.fldC, Form.fldD. what I am trying to do, is put a calculated value into Form.fldD based on the information in fldA - C, i.e.

    Form.fldD = (Tbl.fldA - Tbl.fldB) * Tbl.fldC

    I put this into the Open Form event, but the value it calculates is based on the first record in the form and populates this value to all the other records on the form.

    I then created a private Function within the form as follows:

    Function MyTest(A as double, B as double, C as double) as double
    MyTest = (A - B) * C
    End Function

    In the controlsource of Form.fldD I put the following expression:

    =MyTest([Tbl.fldA]+[Tbl.fldB]+[Tbl.fldC])

    It accepts the expression, but when I run the form #Name? appears in Form.fldD

    I would like to do various are things with the records on the continuous form, such has hi-lite fields if fldD is less then Zero, etc

    Please help... I am aware that in a continuous form you only have 1 current record, even if it is displaying 100's. but not all the records will have a zero value...

    Thanks


    Earl

  2. #2
    nicknameoscar is offline Advanced Beginner
    Windows XP Access 2000
    Join Date
    Apr 2011
    Location
    Earlysville, VA
    Posts
    91
    I tried doing similar things with continuous forms and ran into the same problem. I never found a solution (not that one doesn't exist, I just never found it). If memory serves me correctly the forms I used were based on queries. I ended up modifying the query to give me the totals I was looking for.

    For highlighting of certain controls look at Conditional Formatting. It is under the Design tab when the form is in Design View.

  3. #3
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,956
    Not understanding the issue. Continuous form or otherwise, table or query, expression in textbox ControlSource should calculate just fine. Although might be better to name the other controls different from the field they are bound to then refer to the textbox names in the expression:
    =(tbxA - tbxB) * tbxC
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  4. #4
    nicknameoscar is offline Advanced Beginner
    Windows XP Access 2000
    Join Date
    Apr 2011
    Location
    Earlysville, VA
    Posts
    91
    Sorry, my mistake. I somehow thought the subject was pertaining to unbound controls on a continuous form.

  5. #5
    ETCallHome is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    Mar 2011
    Location
    Limpopo, South Africa
    Posts
    48
    Hi,

    I did call my textbox names differently, let me give a better example than the one before.

    Table1 - 3 fields call OldQty, NewQty,Price
    Texbox Name - txtOldQty bound to OldQty, txtNewQty bound to NewQty, txtPrice bound to Price

    Form1 - 1 field call txtTotal and is unbound

    Function MyTest(A as Double, B as Double, C as Double) as Double
    MyTest = (A -B) * C
    end function

    ControlSource of txtTotal
    =MyTest([txtOldQty]+[txtNewQty]+[txtPrice])

    As mentioned, the expression is accepted, but when I open the form txtTotal displays #Name?

    Maybe this will clarify the problem

    Earl

  6. #6
    ETCallHome is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    Mar 2011
    Location
    Limpopo, South Africa
    Posts
    48
    Hi,

    Figured the problem out...

    ControlSource Property of txtTotal should be

    =MyTest([txtOldQty],[txtNewQty],[txtPrice] and not

    =MyTest([txtOldQty]+[txtNewQty]+[txtPrice] and not

    Thanks for all your advice and taking the time to investigate my problem.

    Earl

  7. #7
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,956
    I should have noticed that error in the function call syntax but I was focusing on the point there should be no need for the function. This just slows down the process. This is a simple calculation and can be accomplished right in the ControlSource.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

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

Similar Threads

  1. Filter a Continuous Form
    By michel_annie22 in forum Forms
    Replies: 7
    Last Post: 11-09-2011, 07:34 AM
  2. Replies: 1
    Last Post: 07-22-2010, 05:55 AM
  3. Replies: 6
    Last Post: 07-21-2010, 05:25 PM
  4. set continuous form height
    By taylorosso in forum Forms
    Replies: 0
    Last Post: 08-31-2009, 05:26 AM
  5. Continuous Form
    By duckie10 in forum Access
    Replies: 13
    Last Post: 06-09-2009, 11:15 AM

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