473,473 Members | 1,861 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Query not updatable...

99 New Member
I have the following tables:

1.Students
Expand|Select|Wrap|Line Numbers
  1. ID     (pk)
  2. Urdu Name
  3. English Name
  4. ....
  5. ....
  6.  
2. Classes
Expand|Select|Wrap|Line Numbers
  1. ClassID   (pk)
  2. Grade
  3. Section
  4. ....
  5. ....
  6.  
3.Students and Classes
Expand|Select|Wrap|Line Numbers
  1. StudentID (related to Students.ID)     | PK
  2. ClassID   (related to Classes.ClassID) | PK
  3. RollNo
  4. ....
  5. ....
  6.  
4. Student Attendance
Expand|Select|Wrap|Line Numbers
  1. ID       (PK)
  2. Student  (StudentID)
  3. Attendance Date
  4. Status
  5.  
Now the issue is that when I make a select query from the tables "Students and Classes" and "Student Attendance" related by StudentID and Student, the resulting query is not updatable. The Query is:
Expand|Select|Wrap|Line Numbers
  1. SELECT 
  2.       [Students and Classes].ClassID
  3.     , [Students and Classes].StudentID
  4.     , [Students and Classes].RollNo
  5.     , [Student Attendance].[Attendance Date]
  6.     , [Student Attendance].Status
  7. FROM 
  8.       [Students and Classes] 
  9.       LEFT JOIN 
  10.       [Student Attendance]
  11.       ON 
  12.       [Students and Classes].StudentID = [Student Attendance].Student;
  13.  
The record is not updatable.
Waiting for any help.
Apr 12 '16 #1
9 2490
jforbes
1,107 Recognized Expert Top Contributor
It sounds about right that your Recordset is not updatable. This may help you understand a little better of what is acceptable and what is not acceptable for the basis of a Form when you want it to be updatable: Why is my query read-only?

Another way to put it is using One-To-Many Joins makes your Recordset Readonly.

Typically in a situation like yours, where you want to update records in multiple tables (or display information from multiple tables), you create a Main/Subform setup where each Form is based on a single table.
Apr 12 '16 #2
mshakeelattari
99 New Member
I have a form that Shows ClassID from table "Classes", with a subform showing StudentID's from "Students and Classes" table. The other form is required to show "Students, Attendance Date, Status" from the "Student Attendance" table for the studentID which have ClassID equal to the ClassID on the former form and the latter should be updatable. Is there anysolution please?
Apr 13 '16 #3
jforbes
1,107 Recognized Expert Top Contributor
I don't currently use Access as my backend database, so I'm a bit rusty on Access' capabilities regarding this. It doesn't quite play by the same rules as SQL Server, and there may be a way to get it updatable by Defining the Relationships of all the tables involved. But I can't guarantee that.

In a case like this, I typically create the SubForm based on the base table (non-query) and then either use a Filter to narrow it down to the Records specific to the MainForm, or supply the an entire RecordSource Select Statement. This is usually updated/assigned to the SubForm in the MainForm's OnCurrent Event. Also in the MainForm's OnCurrent Event, any default values (like Foreign Keys) are defined for the SubForm.

This approach gets a little tricky in the case of a LinkTable, which is what [Students and Classes] happens to be. Especially when Adding a new link, like enrolling a Student in a Class. To make this happen is typically more complex than navigating to the NewRecord and typing in some stuff. It usually takes navigation to one Record (like Classes) and then clicking a button to look up the second Record (like Student) and then clicking another button which takes the two pieces of information and formulates an Insert Statement against the LinkTable and then executes it.
Apr 13 '16 #4
Seth Schrock
2,965 Recognized Expert Specialist
See the following link as it should help you: When can I update data from a query?. It has some suggestions on how to make your query updatable.
Apr 15 '16 #5
mshakeelattari
99 New Member
I am still not understanding what to do...
Apr 17 '16 #6
Seth Schrock
2,965 Recognized Expert Specialist
I think that I understand now what is happening. You need to change your table design for [Students and Classes] to have a single field primary key field instead of a composite key as you have now. You would then change [Student Attendance] to link to this new field instead of the student ID.
Apr 17 '16 #7
mshakeelattari
99 New Member
This is a good idea. I appreciate for this idea. But then, is there a way to preven any duplicate stdent for on class or a duplicate class fo one student in the students and classes table?
Apr 18 '16 #8
Seth Schrock
2,965 Recognized Expert Specialist
It can be done via a multi-field unique index constraint, but personally I would recommend doing it via code (like a DCount() function to see if a record already exists for a particular student and class) as that then allows me to provide a custom error message instead of getting one that Access generates that users won't be able to understand. On your form's BeforeInsert event, just run the test and if a record already exists, then set Cancel = True to stop in insertion of a new record.
Apr 18 '16 #9
NeoPa
32,556 Recognized Expert Moderator MVP
I'd recommend doing it in both if you want a code solution.

It should always be set up to have a unique compound (multi-field) index.

Code can be got around. Tables can be accessed directly. Relying solely on the code is not a wise approach.
Apr 18 '16 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: John Baker | last post by:
Hi: I have two tables, a setup table (TblSetup) and a purchase order table (tblPO). When i construct a query with ONLY the tblPO shown, and a type in parameter for the PO number, I an update...
4
by: John Baker | last post by:
Hi: Most of the time when I do a query and it has no matches, there is a single blank line in the result that I can test. I have one query where no result produces a response with NO lines at...
0
by: Mario Zoratti | last post by:
Hello, everybody, Please be so kind to explain how it is possible to make a query pass through in Access 97 vs SQL server updatable. The query is "SELECT CDC. * FROM CDC": it is very simple and...
2
by: Johnny M | last post by:
I have been using Access since office 4.3. I have just upgraded to Office 2003 and am having issues with creating updatable queries. If I link one table to a selection query based on the same...
2
by: GD | last post by:
tblFoo FooId Name Number 1 One 1 2 Two 2 3 Three 3 The Following query produces the results I want, but it is not updatable. I need at least the...
2
by: Enterprise | last post by:
Hi, Here is my code for the Union query "Table union Table union Table ;" The tables are actually queries themselves. I made a form for the query, but when I try to update the...
2
by: Apple | last post by:
I had create a query with one table and one query, and then create form with that query using wizard, but I can't append or edit data in that form & query. Please help!
4
by: adolph | last post by:
I created 2 tables, each with an autonumber primary key. Fields are: ID (autonumber Primary key) Number (single) Color (Text) FName (text)in one table and LName (text)in the other What I'm...
0
by: CC | last post by:
Dear all, Following Many-to-Many table structure is part of my database ----------------------------------- TbGeneral (dossier information) PK: dsr_id TbDossierSample PK: dsr_sample_id
4
by: usr123 | last post by:
I have got a very simple sql query in access, and i m trying to update the record in the table. It is coming up with the error that use updatable query. What do i need to do to make my query...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.