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 -
Option Compare Database
-
Option Explicit
-
Public DbMain As dao.Database
-
Public RsMain As dao.Recordset
-
Public SqlMain As String
-
-
Private Sub Command3_Click()
-
RsMain.AddNew
-
RsMain.Fields("code") = Me.Text4.Value
-
RsMain.Fields("accode") = Me.Text0.Value
-
RsMain.Fields("name") = Me.Text2.Value
-
RsMain.Update
-
End Sub
-
-
Private Sub Form_Load()
-
-
SqlMain = "SELECT Table1.accode, Table1.Code FROM Table1 INNER JOIN Table2 ON Table1.Code = Table2.maincode"
-
Set DbMain = CurrentDb()
-
Set RsMain = DbMain.OpenRecordset(SqlMain)
-
End Sub
-
-
-
8 13987
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: - Private Sub Form_Load()
-
SqlMain = "SELECT Table1.accode, Table1.Code FROM Table1 INNER JOIN Table2 ON Table1.Code = Table2.maincode"
-
-
Set DbMain = CurrentDb()
-
Set RsMain = DbMain.OpenRecordset(SqlMain)
-
-
MsgBox "This Recordset is: " & IIf(RsMain.Updatable, "Updateable", "Not Updateable")
-
End Sub
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.
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.
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.
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.
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).
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
Sign in to post your reply or Sign up for a free account.
Similar topics
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...
|
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?...
|
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...
|
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...
|
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)=.)),
...
|
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?...
|
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...
|
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...
|
by: Chuck |
last post by:
Can any version of MS Access run in any versions of Linux?
Chuck
--
|
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...
|
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...
|
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
|
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...
|
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...
|
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,...
|
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...
|
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...
|
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...
|
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,...
| |