473,883 Members | 1,763 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

14 New Member
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
8 14019
ADezii
8,834 Recognized Expert Expert
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
ritesh272004
14 New Member
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,584 Recognized Expert Moderator MVP
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
ritesh272004
14 New Member
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,584 Recognized Expert Moderator MVP
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,584 Recognized Expert Moderator MVP
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 Recognized Expert Moderator Specialist
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,584 Recognized Expert Moderator MVP
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
3434
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 pass it to SQL Server for execution or is it better to have all these queries saved like stored procedures and then called from aplication?
14
4201
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? 3) If I create a CD using A2K Developer that includes the runtime version of Access 2K and an installation package, and if someone tries to install the application from the CD, what happens if someone already has Access 2000 or a later version...
7
5596
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 which makes a big Catalogue. A Printed version of the Catalogue is done every 2 Months and we manually create an Index which takes HOURS, the problem is the Catalogue page numbers change depending on New or Deleted product ranges.
2
2018
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 again and it works until I again open a 2003 database...after that same error. has anyone delt with this type of thing in the past. ps this has been going on for a little over a week ..... but I have been using this machine and setup for a year...
4
2803
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)=.)), GIS_EVENTS_TEMP.FSTHARM1 = HarmfulEvent.HarmfulEvent WHERE (((HarmfulEvent.UnitId)=2) AND ((HarmfulEvent.ListOrder)=1) AND ((GIS_EVENTS_TEMP.CASEID)=.));
7
3472
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? Remove _your_teeth_ to reply.
0
1253
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 remote computer. Thanks.
1
1519
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 the table opens fine. I close access and go back to the same table and it hangs again - I've tried this several times and still get the same problem. We are also using Access Run 2k? Has anyone any ideas please - many thanks in anticipation! ...
4
1972
by: Chuck | last post by:
Can any version of MS Access run in any versions of Linux? Chuck --
1
1580
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 would be OK also. Chris
0
9944
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
11153
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10860
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10420
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9583
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7975
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
7134
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5804
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
4225
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.