Solved

How can I update a field in MS Access 2003 via code?

Posted on 2011-03-07
3
226 Views
Last Modified: 2012-05-11
I'm want to keep track of how many times a report is printed.  Here is the code that I have thus far to keep track of the print count.  When I run this, I get a "Field can not be updated." error box.  I'm stumped.  Any suggestions?  

Thank you!

Private Sub btn_incr_prnt_Click()

On Error GoTo Err_btn_incr_prnt_Click

Dim db As Database
Dim rec As Recordset
Dim N As Long

 
Set db = CurrentDb()
Set rec = db.OpenRecordset("Certificates")
N = Me.CertID


MsgBox N
N = N + 1
MsgBox N

Me.CertID = N

Exit_btn_incr_prnt_Click:
    Exit Sub

Err_btn_incr_prnt_Click:
    MsgBox Err.Description
    Resume Exit_btn_incr_prnt_Click
   
End Sub
0
Comment
Question by:NDawg
[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
  • 2
3 Comments
 
LVL 75

Accepted Solution

by:
DatabaseMX (Joe Anderson - Microsoft MVP, Access and Data Platform) earned 500 total points
ID: 35065416
I don't see what you are doing with the Recordset ?

And where are you updating the field ...?
Here Me.CertID = N  ?

If so, are you sure the report Recordsource is updatable ?

Also, is CertID an control on the Report?  If so, be *sure* the Control Name is different that the Control Source ... eg

txtCertID for the Name.

mx
0
 

Author Closing Comment

by:NDawg
ID: 35065699
Ok.  I'm feeling somewhat sheepish...  I forgot about the duplicated control name.  

Many thanks!
0
 
LVL 75
ID: 35065718
Easy to do. It's especially important in Report.  Glad is was that simple.

mx
0

Featured Post

Enroll in May's Course of the Month

May’s Course of the Month is now available! Experts Exchange’s Premium Members and Team Accounts have access to a complimentary course each month as part of their membership—an extra way to increase training and boost professional development.

Question has a verified solution.

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

Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
It’s been over a month into 2017, and there is already a sophisticated Gmail phishing email making it rounds. New techniques and tactics, have given hackers a way to authentically impersonate your contacts.How it Works The attack works by targeti…
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.

738 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