Solved

Open Table to edit in VBA

Posted on 2014-04-20
3
1,520 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
EXCEL Name Matching 13 44
Delete table fields 3 15
Excel Pivot Table question 5 16
Malwarebyte error running MsOffice 2010 5 21
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…
Phishing attempts can come in all forms, shapes and sizes. No matter how familiar you think you are with them, always remember to take extra precaution when opening an email with attachments or links.
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

733 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