|
 |
access thread: event procedure moving to new record
Message #1 by "Howard Stone" <ququmber@h...> on Tue, 18 Dec 2001 13:39:06
|
|
What event would one use call to validate change to a record when you move
to the next record
Thanks
Message #2 by "John Ruff" <papparuff@c...> on Tue, 18 Dec 2001 07:45:18 -0800
|
|
Use the form's BeforeUpdate event
John Ruff - The Eternal Optimist :-)
-----Original Message-----
From: Howard Stone [mailto:ququmber@h...]
Sent: Tuesday, December 18, 2001 1:39 PM
To: Access
Subject: [access] event procedure moving to new record
What event would one use call to validate change to a record when you
move
to the next record
Thanks
Message #3 by John Fejsa <John.Fejsa@h...> on Wed, 19 Dec 2001 08:17:58 +1100
|
|
Depending on you needs you could use object before update event to check
on object only (ie,. text box) or you could form before update to check
all object at once. For example:
Check current object event:
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
Private Sub Year_BeforeUpdate(Cancel As Integer)
On Error GoTo Err_Year_BeforeUpdate
Exit Sub
strTitle =3D "Are you sure?"
strMsg =3D "Funds for this period are only allocated to grants with
current support start date. "
strMsg =3D strMsg & "Deleting the grant's current support start date
"
strMsg =3D strMsg & "will cause the program to delete funds "
strMsg =3D strMsg & "allocated to (" & UCase(Me!Title) & ") grant for
the selected date range. "
strMsg =3D strMsg & "Do you wish to proceed with this action."
lngMsgDialog =3D vbCritical + vbYesNo
If fDataFound Then
If IsNull(Me!GrantDate) Or Me!GrantDate =3D "" Then
beep
intResult =3D MsgBox(strMsg, lngMsgDialog, strTitle)
If intResult =3D vbYes Then
Me!Year =3D Null
Me!SupportEnd =3D Null
DoCmd.SetWarnings False
DoCmd.OpenQuery "qryDeleteGrantFunds"
Me!frmFunds.Form.Requery
DoCmd.SetWarnings True
Else
Cancel =3D True
Me!Year.Undo
fRestore =3D True
Exit Sub
End If
End If
End If
'Check date range
If IsDate(Me!Year) Then 'Check date format
If CDate(Me!Year) < CDate(Me!GrantDate) Then 'Check if support
date < grant date
beep
MsgBox "Current support cannot begin before Grant start date."
& vbCrLf & "Please re-enter support start date to continue.", vbCritical,
"DATA ERROR: Invalid Current Support Date Detected!"
DoCmd.CancelEvent
Exit Sub
End If
If CDate(Me!Year) > CDate(Me!SupportEnd) Then 'Check if support
date > support end date
beep
MsgBox "Current support cannot begin after support end date."
& vbCrLf & "Please re-enter support start date to continue.", vbCritical,
"DATA ERROR: Invalid Current Support Date Detected!"
DoCmd.CancelEvent
Exit Sub
End If
End If
Exit_Year_BeforeUpdate:
Exit Sub
Err_Year_BeforeUpdate:
MsgBox Error$, vbCritical, "Error Updating Support Start Date!"
Resume Exit_Year_BeforeUpdate
End Sub
Check all objects:
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
Private Sub Form_BeforeUpdate(Cancel As Integer)
On Error GoTo Err_Form_BeforeUpdate
'Check MRN
If IsNull(Me!MRN) Or Me!MRN =3D "" Then
Beep
MsgBox "Please enter client's MRN to continue...", vbCritical,
"Data Error! MRN Not Detected!"
DoCmd.CancelEvent
Me!MRN.SetFocus
Exit Sub
End If
If Not IsNumeric(Me!MRN) Then
Beep
MsgBox "Please enter a valid client's MRN to continue...",
vbCritical, "Data Error! Invalid MRN Format Detected!"
DoCmd.CancelEvent
Me!MRN.SetFocus
Exit Sub
End If
'Check Mother Maiden Name
If IsNull(Me!MothersMaidenName) Or Me!MothersMaidenName =3D "" Then
Beep
MsgBox "Please enter client's Mothers Maiden Name to continue...",
vbCritical, "Data Error! Mothers Maiden Name Not Detected!"
DoCmd.CancelEvent
Me!MothersMaidenName.SetFocus
Exit Sub
End If
'Check Title
If IsNull(Me!cmbTitle) Or Me!cmbTitle =3D 0 Then
Beep
MsgBox "Please enter client's title to continue...", vbCritical,
"Data Error! Title Not Detected!"
DoCmd.CancelEvent
Me!cmbTitle.SetFocus
Me!cmbTitle.Dropdown
Exit Sub
End If
'Check First Name
If IsNull(Me!FName) Or Me!FName =3D "" Then
Beep
MsgBox "Please enter client's first name to continue...",
vbCritical, "Data Error! First Name Not Detected!"
DoCmd.CancelEvent
Me!FName.SetFocus
Exit Sub
End If
'Check Surname
If IsNull(Me!Surname) Or Me!Surname =3D "" Then
Beep
MsgBox "Please enter client's surname to continue...", vbCritical,
"Data Error! Surname Not Detected!"
DoCmd.CancelEvent
Me!Surname.SetFocus
Exit Sub
End If
'Check Address
If IsNull(Me!Address) Or Me!Address =3D "" Then
Beep
MsgBox "Please enter client's address to continue...", vbCritical,
"Data Error! Address Not Detected!"
DoCmd.CancelEvent
Me!Address.SetFocus
Exit Sub
End If
'Check Suburb
If IsNull(Me!Suburb) Or Me!Suburb =3D "" Then
Beep
MsgBox "Please enter client's suburb to continue...", vbCritical,
"Data Error! Suburb Not Detected!"
DoCmd.CancelEvent
Me!Suburb.SetFocus
Exit Sub
End If
'Check Postcode
If IsNull(Me!Postcode) Or Me!Postcode =3D "" Then
Beep
MsgBox "Please enter client's postcode to continue...", vbCritical,
"Data Error! Postcode Not Detected!"
DoCmd.CancelEvent
Me!Postcode.SetFocus
Exit Sub
End If
If Not IsNumeric(Me!Postcode) Then
Beep
MsgBox "Please enter a valid numeric postcode to continue...",
vbCritical, "Data Error! Invalid Postcode Detected!"
DoCmd.CancelEvent
Me!Postcode.SetFocus
Exit Sub
End If
If Len(Me!Postcode) < 4 Or Len(Me!Postcode) > 4 Then
Beep
MsgBox "Please enter a valid 4 digit postcode to continue...",
vbCritical, "Data Error! Invalid Postcode Detected!"
DoCmd.CancelEvent
Me!Postcode.SetFocus
Exit Sub
End If
'Check Sex
If IsNull(Me!Sex) Or Me!Sex =3D "" Then
Beep
MsgBox "Please enter client's gender to continue...", vbCritical,
"Data Error! Gender Not Detected!"
DoCmd.CancelEvent
Me!Sex.SetFocus
Exit Sub
End If
'Check DOB
If Not IsDate(Me!DOB) Then 'Check date format
Beep
MsgBox "Please re-enter client's date of birth to continue...",
vbCritical, "Data Error! Invalid Date of Birth Format Detected!"
DoCmd.CancelEvent
Me!DOB.SetFocus
Exit Sub
Else
If IsNull(Me!DOB) Or Me!DOB =3D "" Then 'Check date
Beep
MsgBox "Please enter client's date of birth to continue...",
vbCritical, "Data Error! Date of Birth Not Detected!"
DoCmd.CancelEvent
Me!DOB.SetFocus
Exit Sub
End If
End If
Exit_Form_BeforeUpdate:
Exit Sub
Err_Form_BeforeUpdate:
MsgBox Error
Resume Exit_Form_BeforeUpdate
End Sub
Hope that gives you few ideas...
____________________________________________________
John Fejsa
Systems Analyst/Computer Programmer
Hunter Centre for Health Advancement
Locked Bag 10
WALLSEND NSW 2287
Phone: (02) 49246 336 Fax: (02) 49246 209
____________________________________________________
The doors we open and close each day decide the lives we live
____________________________________________________
CONFIDENTIALITY & PRIVILEGE NOTICE
The information contained in this email message is intended for the named
addressee only. If you are not the intended recipient you must not copy,
distribute, take any action reliant on, or disclose any details of the
information in this email to any other person or organisation. If you
have received this email in error please notify us immediately.
>>> ququmber@h... 19/12/2001 0:39:06 >>>
What event would one use call to validate change to a record when you
move
to the next record
Thanks
This message is intended for the addressee named and may contain confidential information. If you are not the intended recipient,
please delete it and notify the sender. Views expressed in this message are those of the individual sender, and are not necessarily
the views of Hunter Health.
|
|
 |