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!

Prevent data changes

Status
Not open for further replies.

JMM

Technical User
Feb 17, 2000
37
NZ
Is it possible to prevent users changing a date field in form view once a first date has been added?<br><br>Not allowing edits in design view is no good because this prevents data from being added at all.<br><br>Thanks
 
Off the top of my head, in your beforeupdate event, can you check the OldValue property?&nbsp;&nbsp;If it is Null, then the user is entering data for the first time and everything is OK, but if the OldValue is not Null then undo.<br><br>Here is the code to put in the BeforeUpdate event <br><br>&nbsp;&nbsp;&nbsp;If Not (IsNull(Me!YourControlName.OldValue)) Then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;MsgBox &quot;You cannot change a value once it has been entered!&quot;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Cancel = True<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Me!YourControlName.Undo<br>&nbsp;&nbsp;&nbsp;&nbsp;End If<br><br>Hope that helps. <p>Kathryn<br><a href=mailto: > </a><br><a href= > </a><br>
 
Kathryn, It worked perfectly. Thanks very much.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top