Results 1 to 9 of 9
  1. #1
    LuisTeknova is offline Novice
    Windows 7 32bit Access 2003
    Join Date
    Jul 2012
    Posts
    4

    Using dynamic control source expressions on unbound fields


    Hello,

    I will do my best to describe what I have been trying to acheive. I have a report, that currently uses a control source expression to determine a value. Field name "MfgScale" control source "=([StartQty]*([FillVolume]/1000))" I would like to query the control source for MfgScale from a field called "Formula" in another table called OverageCalculations which is a text field with the value "=([StartQty]*([FillVolume]/1000))". The Table OverageCalculations has a "PartNumber" Field which is the unique identifier which means "PartNumber" can have a different formula and the formula can be the control source expression for MfGScale. The report uses a field called ItemID which can be joined with PartNumber. Is this possible? Hope this made sense.

  2. #2
    jzwp11 is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jun 2010
    Location
    Dayton, OH
    Posts
    2,901
    If I understand you correctly, the only way to do what you describe is with VBA code, but even with that I do not think it will work if you are bringing multiple items into the report. The control source of a text box applies to all records within the section in which it is located.

    You said that each part number can have a different formula. How do those formulas differ? Do the formulas differ based on the type of part. So do parts of one type use 1 formula while parts of a different type use a different formula?

    Could you provide some examples? Perhaps there is another way to handle this.

  3. #3
    LuisTeknova is offline Novice
    Windows 7 32bit Access 2003
    Join Date
    Jul 2012
    Posts
    4
    Yes I think you understand correctly. example below
    Table - OverageCalcualtions
    PartNumber | Formula
    Part1 | =([StartQty]*([FillVolume]/1000))
    Part2 | =([StartQty]*([FillVolume]/1000)+1.5)

    Report - BatchRecord
    ItemID = PartNumber
    MfgScale,unbound textbox, control source=OverageCalculation.Formula(expression) where ItemID = PartNumber

    I tried to make this logic work but have only had success making MfgScale's output be =([StartQty]*([FillVolume]/1000)) not control souce expression. I do this as an OnOpen Event of the report.

  4. #4
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    Include OverageCalculations table in report RecordSource by joining pk/fk fields then the related info is available.

    If the only variation in the formula is the overage addition, just include that value in a field then that field can be referenced when the tables are joined.

    =[StartQty]*([FillVolume]/1000)+Nz([OverageFactor],0)

    Is the OverageFactor supposed to be added before multiplication by StartQty?
    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.

  5. #5
    LuisTeknova is offline Novice
    Windows 7 32bit Access 2003
    Join Date
    Jul 2012
    Posts
    4
    By including the table couldnt I then, reference the formula for the control souce for MfgScale while producing the result rather than the formula output? I like the solution above but Im still trying to figure out if this is possible.

    I never thought of using the [OverageFactor] as a varible, but it may work. BUT, not to complicate things.. I used my easiest formula.. going that route I may need two or more [OverageFactor]S per product. example.
    =IF([WKO_StartQty]<3,(([WKO_StartQty]*([FillVolume]/1000))+0.75),IF([WKO_StartQty]<10,(([WKO_StartQty]*([FillVolume]/1000))+1),(([WKO_StartQty]*([FillVolume]/1000))+2)))
    as seen above [OverageFactor] is added after multiplication.
    This may work. but I will just have to see if The overage is the only variation.

  6. #6
    jzwp11 is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jun 2010
    Location
    Dayton, OH
    Posts
    2,901
    I do not think that Access will recognize it as a formula in a query since the value is still in a text field. BTW, if you want to do comparisons in a query you want to use the IIF() function not IF().

  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,929
    I see, that is 3 different overage factors and would require 3 fields in table.

    If you want to store formula as a string in a field then think will need the Eval function, but I have never tried this.

    =Eval([formula field name])
    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.

  8. #8
    LuisTeknova is offline Novice
    Windows 7 32bit Access 2003
    Join Date
    Jul 2012
    Posts
    4
    Yes Thats correct 3 overage factors.

    No Luck with =Eval([formula]) did that and didnt work, but input the value of [formula] into the =Eval() and that worked so I know the formula equation worked, but not the method of using the field name.

  9. #9
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    Then only suggestion is 3 overage factor fields and an IIF() expression, assuming the overage factor is the only variance in the formula:

    =[WKO_StartQty]*[FillVolume]/1000+IIF([WKO_StartQty]<3, 0.75,IIF([WKO_StartQty]<10,1,2))
    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. Replies: 2
    Last Post: 06-05-2012, 12:33 PM
  2. Replies: 1
    Last Post: 03-01-2012, 10:52 AM
  3. Replies: 5
    Last Post: 10-13-2011, 03:36 PM
  4. Formatting Unbound Control
    By SltPhx in forum Forms
    Replies: 12
    Last Post: 08-17-2011, 01:49 PM
  5. Replies: 1
    Last Post: 07-11-2011, 04:35 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