Connecting Tech Pros Worldwide Forums | Help | Site Map

How to lock a field in a record or make it read only in Access 2007

Newbie
 
Join Date: Oct 2009
Posts: 4
#1: Oct 24 '09
Hello,

The codes below worked successfully in Access 2003
Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Current()
  2.   If Me.NewRecord Then
  3.     Me.AllowAdditions = True
  4.     Me.AllowDeletions = True
  5.     Me.AllowEdits = True
  6. Else
  7.     Me.AllowAdditions = True
  8.     Me.AllowDeletions = False
  9.     Me.AllowEdits = False
  10. End If
and
Expand|Select|Wrap|Line Numbers
  1. Sub cmdEdit_Click 
  2. On Error GoTo Err_cmdEdit_Click 
  3.  
  4.    Me.AllowEdits = True 
  5.  
  6. Exit_cmdEdit_Click: 
  7.     Exit Sub 
  8.  
  9. Err_cmdEdit_Click: 
  10.     MsgBox Err.Description 
  11.     Resume Exit_cmdEdit_Click 
  12.  
  13. End sub
It works successfully in Access 2003 but it doesnt work in Access 2007. Please help

Expert
 
Join Date: Jul 2008
Location: Maryland
Posts: 1,176
#2: 4 Weeks Ago

re: How to lock a field in a record or make it read only in Access 2007


I think I remember having a problem with this. I ended up locking/disabling each of the relevant controls.
NeoPa's Avatar
Administrator
 
Join Date: Oct 2006
Location: London - UK
Posts: 15,730
#3: 4 Weeks Ago

re: How to lock a field in a record or make it read only in Access 2007


Can you please expand on :
Quote:

Originally Posted by sweetfalguni View Post

It works successfully in Access 2003 but it doesnt work in Access 2007.

Does it give an error message?
If so what?
Which line does it fail on?
Megalog's Avatar
Expert
 
Join Date: Sep 2007
Posts: 273
#4: 4 Weeks Ago

re: How to lock a field in a record or make it read only in Access 2007


If this has been converted to a Split Form after your 2007 upgrade, it may not work.
You'll have to replace the "Me." with "[Forms]![formname]."

If not, then... I'm not sure =)
Expert
 
Join Date: Jul 2008
Location: Maryland
Posts: 1,176
#5: 4 Weeks Ago

re: How to lock a field in a record or make it read only in Access 2007


In my experience, there was no error message. AllowEdits = False just seems to have no effect.
Reply


Similar Microsoft Access / VBA bytes