Results 1 to 3 of 3
  1. #1
    alonewolf23 is offline Novice
    Windows 7 64bit Access 2010 32bit
    Join Date
    Nov 2011
    Posts
    2

    Sum of Cascading Combo Boxes

    I have created a form with Cascading Combo boxes. The first Combo boxes Populates for text boxes using

    ComboBox 1:

    SELECT CPU.CpuSupplierName, CPU.CpuModel, CPU.CpuCores, CPU.CpuSpdGHz, CPU.CpuPrice, CPU.CpuSocket FROM CPU ORDER BY CPU.CpuSpdGHz;

    TextBox Fills:

    =[ComboCpuSuppName].[column](1)
    =[ComboCpuSuppName].[column](2)
    =[ComboCpuSuppName].[column](3)
    =FormatCurrency([ComboCpuSuppName].[column](4))

    Combox 2:



    SELECT Motherboards.MoboSupplierName, Motherboards.MoboModel, Motherboards.MoboPrice, Motherboards.MoboSocket FROM Motherboards WHERE (((Motherboards.MoboSocket)=[txtCpuSocket]));

    Text Boxes Fills:

    =[ComboMoboSupplier].[Column](1)
    =FormatCurrency([ComboMoboSupplier].[Column](2))
    =[ComboMoboSupplier].[Column](3)

    So the first combo box Is CPU's, The second combo box is restricted only to list the Motherboards that will work with the desired CPU. They work and poulate. I would like to then Add the Two Prices to show a Sum of the Selected combinations. I have tried to sum them in Query which works, then pull that Query Exp. into my Form, but that gives me a #Name?. and i would rather just sum it in the form. Is it possible to Sum
    Cascading Combo Box Values.

    =Nz([ComboCpuSuppName].[Column](4),0)+Nz([ComboMoboSupplier].[Column](2),0).

    I picked that code up somewhere, and it half works. it shows "PricePrice" but does not add them.

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,902
    I presume PricePrice is alias for the actual number values.

    I just tested this and it is concatenating the values. This is because + is old BASIC operator for concatenation as well as sum operator. Use Val function to force Access to recoginze the values as numbers instead of strings.
    =Val(Nz([ComboCpuSuppName].[Column](4),0))+Val(Nz([ComboMoboSupplier].[Column](2),0))

    I have encountered this in expressions in Access controls before. VBA will also concatenate two values if they are both defined as strings, even if they are only number characters.
    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.

  3. #3
    alonewolf23 is offline Novice
    Windows 7 64bit Access 2010 32bit
    Join Date
    Nov 2011
    Posts
    2
    Thank you for you help. It solved my issue, and no i can go and create some more!

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

Similar Threads

  1. Cascading combo boxes
    By Jackie in forum Access
    Replies: 5
    Last Post: 07-26-2013, 09:07 AM
  2. Cascading Combo boxes Problem
    By aamer in forum Access
    Replies: 12
    Last Post: 04-03-2011, 07:11 AM
  3. Cascading combo boxes
    By combine21 in forum Forms
    Replies: 3
    Last Post: 12-02-2010, 12:57 PM
  4. Cascading Combo Boxes
    By desireemm1 in forum Programming
    Replies: 1
    Last Post: 10-05-2009, 06:00 AM
  5. Cascading Combo Boxes
    By gjw1012 in forum Access
    Replies: 1
    Last Post: 07-25-2009, 04:59 PM

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