Is there a form event to...

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

Guest

Is there a form event sort of like "on current" which I think means "on
current record" where as you exit/leave the last field for a record on a
continuous form, you could put some code to check for null values in one of
the fields for that record before letting the user proceed to the next record
on the continous form?
 
Probably the form's BeforeUpdate event is the closest that you will find --
assuming that the record is dirty when you're leaving that last control.
 
OK, how does the BeforeUpdate event on a form work? Are you saying that as
long as the previous record on the continous form had some changes, it can
look for a null in a specific field on that previous record and stop the user
before they proceed to add some info to the next record?

Something like this?
frmF_BeforeUpdate()
If (IS NULL ([forms!][frmF]![txtComment]) Then
MsgBox "Please enter a comment for this record"
Else
End If
End Sub
 
A form's BeforeUpdate event occurs just before a record's changed data are
saved to the underlying table. You can cancel the event if your code finds a
problem with the data. So, for example:

Private Sub Form_BeforeUpdate(Cancel As Integer)
If Len(Me.txtComment.Value & "") = 0 Then
Cancel = True
MsgBox "Please enter a comment for this record!"
Me.txtComment.SetFocus
End If
End Sub

--

Ken Snell
<MS ACCESS MVP>




worksfire1 said:
OK, how does the BeforeUpdate event on a form work? Are you saying that
as
long as the previous record on the continous form had some changes, it can
look for a null in a specific field on that previous record and stop the
user
before they proceed to add some info to the next record?

Something like this?
frmF_BeforeUpdate()
If (IS NULL ([forms!][frmF]![txtComment]) Then
MsgBox "Please enter a comment for this record"
Else
End If
End Sub

Ken Snell (MVP) said:
Probably the form's BeforeUpdate event is the closest that you will
find --
assuming that the record is dirty when you're leaving that last control.
 
Thank you very much!

Ken Snell (MVP) said:
A form's BeforeUpdate event occurs just before a record's changed data are
saved to the underlying table. You can cancel the event if your code finds a
problem with the data. So, for example:

Private Sub Form_BeforeUpdate(Cancel As Integer)
If Len(Me.txtComment.Value & "") = 0 Then
Cancel = True
MsgBox "Please enter a comment for this record!"
Me.txtComment.SetFocus
End If
End Sub

--

Ken Snell
<MS ACCESS MVP>




worksfire1 said:
OK, how does the BeforeUpdate event on a form work? Are you saying that
as
long as the previous record on the continous form had some changes, it can
look for a null in a specific field on that previous record and stop the
user
before they proceed to add some info to the next record?

Something like this?
frmF_BeforeUpdate()
If (IS NULL ([forms!][frmF]![txtComment]) Then
MsgBox "Please enter a comment for this record"
Else
End If
End Sub

Ken Snell (MVP) said:
Probably the form's BeforeUpdate event is the closest that you will
find --
assuming that the record is dirty when you're leaving that last control.

--

Ken Snell
<MS ACCESS MVP>


Is there a form event sort of like "on current" which I think means "on
current record" where as you exit/leave the last field for a record on
a
continuous form, you could put some code to check for null values in
one
of
the fields for that record before letting the user proceed to the next
record
on the continous form?
 
Back
Top