Event before moving to another record

  • Thread starter Thread starter Lars Brownie
  • Start date Start date
L

Lars Brownie

Before a user moves to another record in a form I would like to check
certain field values. This check must always take place. So not only when
the user updates one of the fields but also when he hasn't made any changes.
Which is the right event to put this check in?
Thanks, Lars
 
Lars,
use the Before Update event of the form.
Note that both the form and controls such as textboxes and combos have a
Before Update event.
Be sure you use the before update event for the form.

Here is some sample code from a previous post:

Marshall Barton, MVP suggested the following code.

Set the Tag property of each bound control that you want to check to
something like CHECK. Then you could use a loop like this air code:

Dim ctl As Control
Dim strEmpty As String
Dim strMsg As String
For Each ctl In Me.Controls
If ctl.Tag = "CHECK" Then
If IsNull(ctl) Then
strEmpty = strEmpty & vbCrLf & Ctl.Name
End If
End If
Next ctl
If strEmpty <> "" Then
strMsg = "These fields are missing a value" _
& Mid(strEmpty, 3) & vbCrLf & vbCrLf _
& "are you sure you want to save?"
If MsgBox(strMsg, . . . ) = vbYes Then
Me.Dirty = False
End If
End If


Jeanette Cunningham -- Melbourne Victoria Australia
 
Except that the form's BeforeUpdate event won't fire if the user hasn't made
changes, which Lars says is a requirement (don't understand why, since if it
was okay to save and nothing's changed, it should still be okay...)

The Current event fires once you've moved to the next row, so I'm not sure
there is an event that can be used.
 
Before a user moves to another record in a form I would like to check
certain field values. This check must always take place. So not only when
the user updates one of the fields but also when he hasn't made any changes.
Which is the right event to put this check in?
Thanks, Lars

Why is it necessary to do a check if the user just opens a record and looks at
it??? If it was checked before it was entered, and before every time it was
changed (using the Form's BeforeUpdate event as Jeanette suggests), it
shouldn't need checking if it's just passively viewed.

That said... it would be tough to do so. The form's Current event fires when
you *have moved* to a new record, but I'm not aware of any event which fires
*before* the move.
 
Thanks all for your answers.
I changed the database design which makes the option unnecessary.

Lars
 

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

Similar Threads


Back
Top