473,395 Members | 1,905 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Ms Access Err - Run-time error '3027': Cannot Update. Database or object is read-only

Hi,

Could you help me with the below code from Ms Access. I am trying to add data to an access table. FE and BE in the same file. However i get the error as

Run-time error '3027': Cannot Update. Database or object is read-only



Expand|Select|Wrap|Line Numbers
  1. Option Compare Database
  2. Option Explicit
  3. Public DbMain As dao.Database
  4. Public RsMain As dao.Recordset
  5. Public SqlMain As String
  6.  
  7. Private Sub Command3_Click()
  8. RsMain.AddNew
  9. RsMain.Fields("code") = Me.Text4.Value
  10. RsMain.Fields("accode") = Me.Text0.Value
  11. RsMain.Fields("name") = Me.Text2.Value
  12. RsMain.Update
  13. End Sub
  14.  
  15. Private Sub Form_Load()
  16.  
  17. SqlMain = "SELECT Table1.accode, Table1.Code FROM Table1 INNER JOIN Table2 ON Table1.Code = Table2.maincode"
  18. Set DbMain = CurrentDb()
  19. Set RsMain = DbMain.OpenRecordset(SqlMain)
  20. End Sub
  21.  
  22.  
  23.  
Oct 13 '11 #1

✓ answered by NeoPa

You may find Reasons for a Query to be Non-Updatable helpful in that respect. Good luck :-)

8 13987
ADezii
8,834 Expert 8TB
It's possible that the Recordset itself is Not Updateable, add a Line of Code (Code Line #7) to the Load() Event to find out for sure:
Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Load() 
  2. SqlMain = "SELECT Table1.accode, Table1.Code FROM Table1 INNER JOIN Table2 ON Table1.Code = Table2.maincode" 
  3.  
  4. Set DbMain = CurrentDb() 
  5. Set RsMain = DbMain.OpenRecordset(SqlMain) 
  6.  
  7. MsgBox "This Recordset is: " & IIf(RsMain.Updatable, "Updateable", "Not Updateable")
  8. End Sub
Oct 13 '11 #2
Yes Adezii

I checked with your line of code and you are correct the recordset is not updatable. But i have used this code earlier and have never found such issue.

It would be great if you could help to make it updatable.
Oct 13 '11 #3
NeoPa
32,556 Expert Mod 16PB
Let's start by sending you off on a quick detour to When Posting (VBA or SQL) Code. We don't know which line is causing the problem unless you tell us.

Now, with that out of the way, it seems to me you have a much more fundamental problem even than the one you ask for help with. It seems to me you are trying to code around Access instead of using Access to do the work it was designed to do. Access forms are designed to handling updating of data automatically. You are only making life complicated for yourself by tring to update the table using recordset programming. Let the form do what it was designed to do easily.
Oct 13 '11 #4
Hi Guru,

I know access can handle on its own but what i am trying is through recordset programming.

Infact i have done this earlier and it worked , but do not understand why it wont work now.
Oct 13 '11 #5
NeoPa
32,556 Expert Mod 16PB
In that case why not start by providing the missing information we would need in order to help you, as I mentioned in post #4? We may be psychic, but you should never rely on it.
Oct 13 '11 #6
NeoPa
32,556 Expert Mod 16PB
ritesh272004:
I know access can handle on its own but what i am trying is through recordset programming.
The obvious question is why anyone in their right mind would even want to make their own situation more complicated by taking such an unprofitable approach. I cannot stress enough how bad an idea this is. I've seen programmers spending all their time down this ever-shrinking blind alley, simply because it never occurred to them to find the easier way. If you know the better way but still choose to do it the harder way then just don't say I didn't warn you (and all the other unfortunates that may happen to come across this thread at other times).
Oct 13 '11 #7
Stewart Ross
2,545 Expert Mod 2GB
As NeoPa has indicated forcefully, using recordset programming in place of the in-built facilities is likely to prove a frustrating experience unless you have very good reason to do so.

When you ran Adezii's check it confirmed that the recordset you are trying to update is NOT updateable. This is a good indication that you have got something fundamental wrong. This has nothing to do with the code which you tell us you have used before. It is to do with the tables (unhelpfully named table1 and table2) you have joined together, which are not related in a way that Access can update.

No amount of work on recordsets (or forms) will help you if you don't know how to relate two tables so that they are updateable when joined.

I'd suggest a fundamental rethink of your approach, before you go down the code-it blind alley you face here.

-Stewart
Oct 13 '11 #8
NeoPa
32,556 Expert Mod 16PB
You may find Reasons for a Query to be Non-Updatable helpful in that respect. Good luck :-)
Oct 13 '11 #9

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

Similar topics

6
by: Jegger | last post by:
Hello! We have following situation; network with 100 users, aplication developed in Access, user DB deployed on SQL Server. Is it better to create query inside aplication (with code) and then...
14
by: wolftor | last post by:
1) Is there a free runtime version of Access available that is more recent than the one for Access 2000? 2) If I create an application (MDE) in A2K, will it run on all later versions of Access?...
7
by: Ross Hamilton | last post by:
I have a Report that creates a Catalogue of Products we sell under various Headings eg: Books, Recordings, Health Food, Diet Foods, etc There are 82 Headings and a total of 6000+ products...
2
by: sparks | last post by:
I have both installed on win2000. 97 works fine until I run 2003. then when I try to run 97 I get out of memory, please close some programs and try again...this is from cold boot. I install 97...
4
by: meyvn77 | last post by:
UPDATE GIS_EVENTS_TEMP SET GIS_EVENTS_TEMP.FSTHARM1 = HarmfulEvent.HarmfulEvent WHERE (((HarmfulEvent.UnitId)=1) AND ((HarmfulEvent.ListOrder)=0) AND ((GIS_EVENTS_TEMP.CASEID)=.)), ...
7
by: haggis | last post by:
Is there anywhere I can buy an older version (simply for the hoped-for lower price) of Access? Will it run as a stand-alone? Or do I need the corresponding older version of Office and/or OS?...
0
by: adnanahmed714 | last post by:
Hi Experts! i made a application for plant monitoring.Can some one help me , to access(Run+ Monitor) VB application from other Computer on the Network. I just want to monitor the forms on the...
1
by: Gillyd | last post by:
Hi Everyone We are using DB2 with Access 2k. When I go to open a table from an existing .mdb access hangs - task manager reports it's not responding. I copy the tables I need to a new .mdb and...
4
by: Chuck | last post by:
Can any version of MS Access run in any versions of Linux? Chuck --
1
CougarMutt
by: CougarMutt | last post by:
Is there a way to initiate access, run a report, save it to a network location, and exit the application all from a scheduled task? Emailing it would be just as good, but if I can save it that...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.