• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 236
  • Last Modified:

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

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 Sub

    MsgBox Err.Description
    Resume Exit_btn_incr_prnt_Click
End Sub
  • 2
1 Solution
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database ArchitectCommented:
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.

NDawgAuthor Commented:
Ok.  I'm feeling somewhat sheepish...  I forgot about the duplicated control name.  

Many thanks!
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database ArchitectCommented:
Easy to do. It's especially important in Report.  Glad is was that simple.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Get 10% Off Your First Squarespace Website

Ready to showcase your work, publish content or promote your business online? With Squarespace’s award-winning templates and 24/7 customer service, getting started is simple. Head to Squarespace.com and use offer code ‘EXPERTS’ to get 10% off your first purchase.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now