Results 1 to 6 of 6
  1. #1
    jamesborne is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Dec 2011
    Posts
    13

    Creating an Updateable query even when linking another table.

    Hello there!


    I am trying to create a POS db but I have hit rock bottom.
    Here are the tables I have:

    ProductT:
    ProductID
    Product Name

    PriceT:
    ProductID
    Price
    PriceStartDate

    OrderT:
    ProductID
    Quantity

    Now Here's my query:
    ProductID (From OrderT or ProductT)
    Quantity (From OrderT)
    Max(Price) (From PriceT)

    Problem: As soon as I add PriceT to the query it becomes in-updateable and I cannot add new records to the query.

    Think you can solve it?
    Cheers

    J. Borne

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    Show the query SQL statement.

    Issue is the aggregate function Max(). SQL aggregate functions must be used in a GROUP BY (totals) query.

    You could use DMax, a domain aggregate function.

    Calculated values in a query or in textbox ControlSource will not save to table.
    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
    jamesborne is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Dec 2011
    Posts
    13
    SELECT OrderSubT.ProductID, OrderSubT.Quantity, PriceT.Price, [Quantity]*[Price] AS SubTotal
    FROM PriceT INNER JOIN (OrderT INNER JOIN OrderSubT ON OrderT.OrderID =OrderSubT.OrderID) ON PriceT.ProductSubID = OrderSubT.ProductSubID;

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    Not seeing Max in that query. Is there more than one price record for each product? If so, the query will not be editable with a direct join and cannot include PriceT table.

    Options:

    Search Price table for the most current price and VBA code to save the found PriceID or actual price value.

    Select price from a bound combobox list.
    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
    jamesborne is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Dec 2011
    Posts
    13
    Regarding your option: "Search Price table for the most current price and VBA code to save the found PriceID or actual price value.", do you mean using DLookup in the form?

    Thanks

  6. #6
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    Would be a little more complicated. Getting the syntax correct for nested domain aggregate functions is tricky when used in query or textbox ControlSource. I assume the ID fields are all number type.

    DLookup("Price", "PriceT", "PriceStartDate=#" & DMax("PriceStartDate", "PriceT", "ProductID=" & [ProductID]) & "#")

    Possible issue during data entry is that the ProductID is not known when the record is initiated. I think the expression will recalculate as soon as the ProductID is selected.

    Do you want the price saved to OrderT? You don't show a field for the price.
    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. Macro to trigger emailing an updateable table
    By KOIBOY in forum Import/Export Data
    Replies: 5
    Last Post: 09-10-2011, 05:46 AM
  2. Must use updateable query
    By adams.bria in forum Queries
    Replies: 1
    Last Post: 08-29-2011, 10:31 AM
  3. Need Query To Be Updateable
    By robsworld78 in forum Queries
    Replies: 11
    Last Post: 07-17-2011, 09:06 PM
  4. Creating a form while linking two tables
    By sai_rlaf in forum Forms
    Replies: 1
    Last Post: 04-29-2011, 02:08 PM
  5. Trouble linking a table to a query
    By wtubell in forum Queries
    Replies: 1
    Last Post: 03-26-2009, 06:34 PM

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