Solved

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

Posted on 2011-03-07
3
222 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 - Access MVP) 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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Today's users almost expect this to happen in all search boxes. After all, if their favourite search engine juggles with tens of thousand keywords while they type, and suggests matching phrases on the fly, why shouldn't they expect the same from you…
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…
Familiarize people with the process of utilizing SQL Server functions 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 Ac…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

760 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

19 Experts available now in Live!

Get 1:1 Help Now