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

Error message displays for new record when I enter new value

Status
Not open for further replies.

torf66

Programmer
Jun 10, 2003
43
0
0
US
I have this code in my form it works great when the user tries to change something in a field that already has a value in it. The field is numAdmitNumber. But my problem is when the go to enter a new record and the enter 123 in the numAdmitNumber then tab to the next field and they realize the numAdmitNumber should have been 321 if they go back to the numAdmitNumber field and try to change it then the message "No changes possible" displays. I do not want this message to display when they need to correct a mistake when adding a new record in this field numAdmitNumber. How can I do that?




Private Sub numAdmitNumber_GotFocus()

numAdmitNumber.Locked = Not NewRecord

End Sub


Private Sub numAdmitNumber_KeyDown(KeyCode As Integer, Shift As Integer)
If (Not IsNull(numAdmitNumber)) And (KeyCode >= 32) And numAdmitNumber.Locked = Not NewRecord Then
MsgBox "No changes possible"
End If
End Sub

 
torf66

I suspect there are variations on this.

The current record has certain properties that should help you for this issue.

if me.dirty then
'dirty value set to true saved record has been modified
'logic to block the change
else
'record is either new or has not been changed
end

You can actually use this logic with the on current record, and then lock the field that you don't want the user to change.

i.e.

if me.dirty then
me.numAdmitNumber.Enabled = False
else
me.numAdmitNumber.Enabled = True
end

Two other values I find useful are

me.numAdmitNumber.value
vs
me.numAdmitNumber.oldvalue

Where I can swap the original and new values

Richard
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top