Solved

Open Table to edit in VBA

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

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

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

Suggested Solutions

My experience with Windows 10 over a one year period and suggestions for smooth operation
This article descibes how to create a connection between Excel and SAP and how to move data from Excel to SAP or the other way around.
The viewer will learn how to simulate a series of coin tosses with the rand() function and learn how to make these “tosses” depend on a predetermined probability. Flipping Coins in Excel: Enter =RAND() into cell A2: Recalculate the random variable…
The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …

948 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

21 Experts available now in Live!

Get 1:1 Help Now