unable to edit with results of a query (1 Viewer)

maheshashish

Registered User.
Local time
Today, 12:28
Joined
Feb 22, 2017
Messages
20
Dear Members,

I am trying to write a small piece of database, who owns a medical shop. Which is an medicines inventory management database. But when ever I try to pull a query for sales entry via query, I am getting a result which is ultimately unable to edit.
I am working with these tables
"MedicinesEntryT" for entering details about medicine, like name and manufacturer etc.
"PurchaseDetailsT" for entering the variable details about medicine like the expiry date, cost of that batch of medicine etc.
"PurchaseInvoiceT" which stores, the invoice number of purchase and dealer information etc.

Now I am successfully able to have the purchase form with the help of a query that joins the three.

But for making sales entry I have used a query which takes some information from " SalesDetailsT" , "medicinesentryT", "PurchaseDetailsT". Now when I run the query the table is uneditable, kindly help me with this issue. I am attaching the database along.

Thanking you advance
 

Attachments

  • Medical Database.zip
    1.8 MB · Views: 78

pbaldy

Wino Moderator
Staff member
Local time
Yesterday, 23:58
Joined
Aug 30, 2003
Messages
36,123
I only have 2010 so can't work with the file. In general, I only have forms bound to a single table. Combo boxes can get selections from a different table without the form including that table. Like if I'm choosing a product for a sale, the form would be bound to the sale table but a product combo would get its selections from the products table.
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 02:58
Joined
Feb 19, 2002
Messages
43,213
1. You are using table level lookups. Remove them before proceeding. They will cause nothing but problems once you try to work with them using VBA or queries. Not to mention that they obfuscate the actual value in a particular column.
2. Use discipline in your naming conventions. Once the table-level lookups are gone, the name you want to use for each FK column will be clearer. Typically, you should use the PK name from the parent table as the FK name in the child table. You have done that in a couple of cases but not everywhere. You also have used the same PK name for two tables (PurchaseID). One of them should be changed.
3. The relationship diagram shows two m-m relationships with separate junction tables.

Your query includes two of the junction tables and that is going to produce a nonsensical resultset. Let me change the example to something we can all picture. You have a Student table (MedicinesEntryT), The students has classes and those are placed in a junction table named StudentClass (PurchaseDetaisT) and the other side of the relationship is classes (PurchaseInvT). Students also have Pets and those are stored in StudentPet (SalesDetailsT) and the other side of that relationship is AnimalType (SalesInvT)

What you are doing is creating a query that joins students to classes and pets. What you end up with is:
Joe, Math, Spot
Joe, Math, Peaches
Joe, English, Spot
Joe, English, Peaches
Joe, History, Spot
Joe, History, Peaches

In addition to making no sense, you end up with a Cartesian product which is not updateable.

These three tables cannot be used in the same query. To display the data from all of them, you will need to use a main form for Medicines and subforms (one for each junction table and the right side table)
 

Users who are viewing this thread

Top Bottom