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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

In Access I want to make a field on a form to be data entry only once 3

Status
Not open for further replies.

torf66

Programmer
Jun 10, 2003
43
US
If I have a field in my database that is the user name, I want that user name to be able to be entered into only on the first entry into the record. For example I enter a new
record in the database and I have a field in the database called Initiated By that will contain the users name who initiated the record. Then if I need to edit that record then I cannot enter a name in teh Initiated By field again because data is already entered that tells me who this record was initiated by. Is there a way on a form to make a field be a data entry only field when there is nothing in that field for that particular record. Any suggestions would be greatly appreciated.
Thanks,
Todd ttorfin@dakcl.com
 
Yes, in the form's OnCurrent event, add:

If Me.[Initiated By] = "" Then
Me.[Initiated By].Locked = False
Else
Me.[Initiated By].Locked = True
End If
 
Private Sub YourTextBox_GotFocus()
Me("YourTextBoxName").Locked = Not NewRecord
End Sub

This will leave the textbox unlocked while you're adding a new record and will lock it for existing records. You must make sure user enters something in the textbox - Required property of the field in the table set to True.

Good luck



[pipe]
Daniel Vlas
Systems Consultant

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top