Results 1 to 10 of 10
  1. #1
    Thomasso is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Nov 2016
    Location
    Czech Republic
    Posts
    277

    How to make complex queries editable?

    Hello,



    I have created queries that are based on for example 6 tables (Companies, Orders, Products, OrderDetails, etc...). I have found out that I cannot edit the records in this query which is a big problem for me, since I am creating forms based on this query.

    I am also using TOTALS (GROUP BY etc.).

    How do I make this kind of query editable? Sorry for foreign language, I tried to translate the core so you can understand the query.

    Click image for larger version. 

Name:	query1.png 
Views:	24 
Size:	62.9 KB 
ID:	27304

    It is a query called: Supplier list (Orders and OrderDetails are there because I am counting turn over for each supplier).

    Thank you
    Tomas

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,641
    You can't; the totals query alone will make it read only, even on one table. Other thoughts and reasons:

    http://allenbrowne.com/ser-61.html
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    Thomasso is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Nov 2016
    Location
    Czech Republic
    Posts
    277
    Ah, ok, thanks for the link. What would you recommend to do when I need to input new orders through a form?

    I have these tables: Customers, Orders, OrderDetails, Products.

    I need to select a customer from the Customers table, add a new record into Orders table, then insert units to OrderDetails table and choose product types. How do I make this form work?

    I need totals functionality for the total price etc. What do you recommend about this? A separate query?

    Thank you,
    Tomas

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,641
    For customers and such, I'd use a combo box that got its selections from the customer table, but was bound to the customer field in the orders table. Normally orders and order details would be displayed with a form/subform, so the main form would only be bound to the orders table, the subform to the details table.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  5. #5
    Thomasso is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Nov 2016
    Location
    Czech Republic
    Posts
    277
    Ok, I followed your advice and I think it is gonna work.

    I have created many queries and I am starting to get lost in them. In your personal experience, when is it better to create a query and when is it better to stick to tables?

    All data inputs should be connected to tables and read only data to queries? How do I choose?

    Thank you,
    Tomas

  6. #6
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,641
    There are those that would advocate always using a query behind a form. I don't see a problem binding a form directly to the table...but...I always either open the form with a wherecondition or in data entry mode. As a rule you don't want to open a form bound to a table/query that includes all records, or you'll have performance problems when that table gets larger.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  7. #7
    Join Date
    Jun 2015
    Location
    Wales. Land of the sheep.
    Posts
    1,228
    Just as a note. you can edit the SQL for the forms even if its not linked to a query. Basically you do make a query for that form but its not displayed in the left bar with the other query's.

    If that makes sense. I have a bit of OCD keeping my everything to a minimum. haha

  8. #8
    Thomasso is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Nov 2016
    Location
    Czech Republic
    Posts
    277
    Thanks for the tip. However, I decided to do the following:

    I will build queries for all the read-only forms, like overviews, navigation screens, etc. And all the data entry forms (add new customer, edit order etc.) will be connected to tables. That is a fine approach, isn't it?

    Cheers,
    Tomas

  9. #9
    Join Date
    Jun 2015
    Location
    Wales. Land of the sheep.
    Posts
    1,228
    yea that wont be an issue unless you want to add data to more than one table.... but even then you just click on form in design view and edit "record source" in the data properties tab. Then its the same as any query.

  10. #10
    Micron is offline Very Inert Person
    Windows 7 32bit Access 2007
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    13,368
    I would not be above temporarily storing Totals query values in a temp table so to allow other updates through a query based on multiple. Note, I'm not saying I would then store those calculations anywhere as part of the query update. That being the case, why are aggregate functions (totals or otherwise) part of a query that is being used to update if not to store those values? Most of us here do not and would not store calculations 99.98% of the time.

    Looks to me that you are using lookup fields in your tables too (but I might just be looking at the results of a defined relationship when I see the minus signs). I wonder if the totals query was removed would the update fail anyway? Have to say I don't know because lookup fields in a table are another questionable practice that I'd try to stay away from.
    Last edited by Micron; 01-31-2017 at 03:44 PM. Reason: clarification
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

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

Similar Threads

  1. How to make an editable query?
    By cmb in forum Queries
    Replies: 5
    Last Post: 09-29-2014, 11:41 AM
  2. Replies: 5
    Last Post: 07-15-2014, 09:56 PM
  3. Replies: 12
    Last Post: 11-21-2012, 01:51 PM
  4. Make sub query un-editable
    By esh112288 in forum Forms
    Replies: 2
    Last Post: 11-11-2012, 06:35 PM
  5. Populate Form And Make Editable
    By Rick5150 in forum Forms
    Replies: 1
    Last Post: 10-04-2011, 09:04 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