Undo unbound text box value on a form

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.
 
M

Marshall Barton

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.
 
G

Guest

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top