Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Lock a field after it has been updated once 1

Status
Not open for further replies.

mobile2

Programmer
Dec 19, 2002
38
GB
I am using MS Access 97 and want to lock a field after it has been updated. I have used Edit command buttons in the past but would like to know if there a way to tell the database to lock the field automatically after the date has been entered. I welcome your advice.
 
On the after update of the field:

Code:
Me.[i][b]OTHER FIELD[/b][/i].SetFocus
Me.[i]Field Name[/i].Enabled = False

You have to set the focus to another field because you can't disable a field that has focus.
 
the above will work, but if your using continuous forms then that will lock the field continuously, what you need is to do is set the fields locked property to true then use the oncurrent event of the form and have it check the field, if its empty then have the code set the field to enabled

"My God! It's full of stars...
 
Thank you both for your advice. The first code "dcurtis" supplied works perfect for what I want but when I added code "scottian" to the oncurrent property for the form the field wont allow me to edit at all.

Can you please confirm what I'm doing wrong:

Private Sub Form_Current()
If Me.DateCustomerActive Is Null Then
Me.DateCustomerActive.Enabled = False
End If

Private Sub DateCustomerActive_AfterUpdate()
Me.FirstContact.SetFocus
Me.DateCustomerActive.Enabled = False

Thanks again

 
Try this...

If IsNull(Me.DateCustomerActive) Or Me.DateCustomerActive = "" Then .......



Randy
 
I tried the following and it works great:

If IsNull(Me.DateCustomerActive) Or Me.DateCustomerActive = "" Then
Me.DateCustomerActive.Enabled = True
Else
Me.DateCustomerActive.Enabled = False
End If

Cheers
 
And a one-line solution:
Me.DateCustomerActive.Enabled = (IsNull(Me.DateCustomerActive) Or Me.DateCustomerActive = "")

Hope This Help, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top