Solved

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

Posted on 2011-03-07
3
225 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
  • 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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

When you are entering numbers in a speadsheet, and don't remember what 6×7 is, you just type “=6*7" instead. It works in every cell! This is not so in Access. To enter the elusive 42 in a text box, you have to find a calculator, and then copy the re…
QuickBooks® has a great invoice interface that we were happy with for a while but that changed in 2001 through no fault of Intuit®. Our industry's unit names are dictated by RUS: the Rural Utilities Services division of USDA. Contracts contain un…
Familiarize people with the process of utilizing SQL Server views from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Access…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…

828 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