Check if field has got data before navigating to next record

scheeps

Registered User.
Local time
Tomorrow, 12:22
Joined
Mar 10, 2011
Messages
82
I've got the following scenario, a user needs to add a note in the Notes field if he has changed the Data Status combo box. For example, he needs to state a reason in the Notes field why he updated the Data Status field from "Active" to "Inactive".

How can I check this before the user navigates to the next record?

First I need to check if the Data Status combo has been updated (presume I can use this code:
Code:
If Nz(Me.cboDataStatus.OldValue, "") <> Nz(Me.cboDataStatus, "") then
and then also if Me.txtNotes <> ""

Which event will allow me to do this? I've tested the On Current event but with no luck.

Hope someone will point me in the right direction.
 
The field must be bound to a record because you are talking about moving to the next record. Therefore, the form Before_Update event will be functional. That event will fire before writing the form contents back to the underlying record. It is also an event that can be canceled, so you could do some checking inside the Before_Update event and if your conditions aren't met, pop up a message box (see MsgBox function) to complain. You also need to block off the Form_Close event because that would also update the record (without navigating).

On Current is either too early or too late, depending on how you wanted to do what you were doing. In a Form_Current routine, the event says, in effect: After whatever you did immediately before this moment, the form and its underlying record now match. The form is Current with respect to the record (and/or the record is current with respect to the form.) If you wanted to catch an update, Current is too late - the update has already occurred. When that happens, the control .Value and .OldValue property will always match.
 
Thanks Doc, it makes sense. Good explanation as well.

I've got it working.
 

Users who are viewing this thread

Back
Top Bottom