Solved

Open Table to edit in VBA

Posted on 2014-04-20
3
1,475 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

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Microsoft Office Picture Manager is not included in Office 2013. This comes as a shock to users upgrading from earlier versions of Office, such as 2007 and 2010, where Picture Manager was included as a standard application. This article explains how…
As tax season makes its return, so does the increase in cyber crime and tax refund phishing that comes with it
The viewer will learn how to simulate a series of sales calls dependent on a single skill level and learn how to simulate a series of sales calls dependent on two skill levels. Simulating Independent Sales Calls: Enter .75 into cell C2 – “skill leve…
The viewer will learn how to use a discrete random variable to simulate the return on an investment over a period of years, create a Monte Carlo simulation using the discrete random variable, and create a graph to represent the possible returns over…

776 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