Undo unbound text box value on a form

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

The following is a part of my validation on the BeforeUpdate event procedure
of an unbound text box (Me!PndCk18In1) on my form. My issue is that although
it captures and prompts the "error" this line (Me!PndCk18In1.Undo '**ISSUE**)
does not seem to work therefore after the prompt it still places that value
in that text box. I have used this approach on bound text boxes with no
issues so I'm not sure what's going wrong with the unbound text
boxes...please help.

'Check for Project start time
If IsNull(Me!In.Value) Then
Cancel = True
MsgBox "Missing [TIME: In]. Project has not begun.",
vbExclamation, "TIME ERROR"
Me!PndCk18In1.Undo '**ISSUE**
Exit Sub
End If

Thank you in advance for you assistance.
 
AccessARS said:
The following is a part of my validation on the BeforeUpdate event procedure
of an unbound text box (Me!PndCk18In1) on my form. My issue is that although
it captures and prompts the "error" this line (Me!PndCk18In1.Undo '**ISSUE**)
does not seem to work therefore after the prompt it still places that value
in that text box. I have used this approach on bound text boxes with no
issues so I'm not sure what's going wrong with the unbound text
boxes...please help.

'Check for Project start time
If IsNull(Me!In.Value) Then
Cancel = True
MsgBox "Missing [TIME: In]. Project has not begun.",
vbExclamation, "TIME ERROR"
Me!PndCk18In1.Undo '**ISSUE**
Exit Sub
End If


The Undo method (and the OldValue property) only operate on
bound controls.

To capture the value before it is edited, use the control's
Enter event to save its value to a module level variable.
Then you can restore the value from the variable.
 
Thank you.

Marshall Barton said:
AccessARS said:
The following is a part of my validation on the BeforeUpdate event procedure
of an unbound text box (Me!PndCk18In1) on my form. My issue is that although
it captures and prompts the "error" this line (Me!PndCk18In1.Undo '**ISSUE**)
does not seem to work therefore after the prompt it still places that value
in that text box. I have used this approach on bound text boxes with no
issues so I'm not sure what's going wrong with the unbound text
boxes...please help.

'Check for Project start time
If IsNull(Me!In.Value) Then
Cancel = True
MsgBox "Missing [TIME: In]. Project has not begun.",
vbExclamation, "TIME ERROR"
Me!PndCk18In1.Undo '**ISSUE**
Exit Sub
End If


The Undo method (and the OldValue property) only operate on
bound controls.

To capture the value before it is edited, use the control's
Enter event to save its value to a module level variable.
Then you can restore the value from the variable.
 
Back
Top