Solved

Open Table to edit in VBA

Posted on 2014-04-20
3
1,427 Views
Last Modified: 2014-04-20
Hello,

here is a code

    Dim rs As Recordset
    Set rs = CurrentDb.OpenRecordset("tblproduct2000")

     hideFlag = Application.DLookup("Scol1", "ARR2", "iCode = " & Chr(34) & rs.Fields(0) & Chr(34))
        If hideFlag <> "" Then
           ' Stop
            rs.Fields(10).Value = hideFlag
Bu i am getting an error saying it cant edit....what am i missing?

Thank you
error-Access.png
0
Comment
Question by:Rayne
3 Comments
 
LVL 15

Assisted Solution

by:unknown_routine
unknown_routine earned 200 total points
ID: 40011654
By default recordsets are opened read only.

To make it editable use this:

Set rs = CurrentDb.OpenRecordset(sSQL, dbOpenDynaset, 0, dbOptimistic)
0
 
LVL 29

Accepted Solution

by:
IrogSinta earned 300 total points
ID: 40011656
Whenever you update a record in a DAO recordset, you need to use the Edit and Update recordset methods like so:

rs.Edit
rs.Fields(10).Value = hideFlag
rs.Update

Open in new window

Ron
0
 

Author Comment

by:Rayne
ID: 40011693
Thank IrogSinta and UnknownRoutine
Thank you :)
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
Learn how to make your own table of contents in Microsoft Word using paragraph styles and the automatic table of contents tool. We'll be using the paragraph styles in Word’s Home toolbar to help you create a table of contents. Type out your initial …
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now