Another Validation Question

matthewnsarah07

Registered User.
Local time
Today, 12:17
Joined
Feb 19, 2008
Messages
192
I have a button on a form which sends off detail of a staff members holiday request after it is authorised
I get a number of forms each week where the field [Accept] is still on it default setting of "Awaiting TM Approval".

By button has the following code, what do I need to add so that if [Accept] is still equal to its default a message box pops up and the email does not send until they complete the field??

Thanks for your help

Code:
Private Sub Command29_Click()
On Error GoTo Err_Command29_Click
 
DoCmd.SendObject acSendNoObject, , rtf, "[EMAIL="Email@Email.uk"]Email@Email.uk[/EMAIL]", Me.Staff_Name, , "Cumbria Leave Request Number " & Me.Request_Number & " has been " & Me.Accept_etc, "Line Manager Notes:" & vbCrLf & vbCrLf & Me.TM_Notes & vbCrLf & vbCrLf & "You will receive an automated receipt from Leave Manager shortly", No, No
    
    MsgBox "Thank You! Your Leave Update was Successful", vbOKOnly, "Information"
'   MsgBox MailOutLook.Body
Exit_Command29_Click:
    Exit Sub
Err_Command29_Click:
    MsgBox Err.Description
    Resume Exit_Command29_Click
End Sub
 
Try

If Me.ControlName <> Me.ControlName.DefaultValue Then
 
If you have default value of the control (in the control properties) as a string, e.g. "Example", then the following should work ....

Code:
Private Sub Command29_Click()
On Error GoTo Err_Command29_Click

If Me.txtAcceptControlName = Mid(Me.txtAcceptControlName.DefaultValue, 2, Len(Me.txtAcceptControlName.DefaultValue) - 2) Then
   MsgBox "The whatever field still has the default value."
Else
   DoCmd.SendObject acSendNoObject, , rtf, "[EMAIL="Email@Email.uk"]Email@Email.uk[/EMAIL]", Me.Staff_Name, , "Cumbria Leave Request Number " & Me.Request_Number & " has been " & Me.Accept_etc, "Line Manager Notes:" & vbCrLf & vbCrLf & Me.TM_Notes & vbCrLf & vbCrLf & "You will receive an automated receipt from Leave Manager shortly", No, No
    
   MsgBox "Thank You! Your Leave Update was Successful", vbOKOnly, "Information"
'   MsgBox MailOutLook.Body
 
End If
Exit_Command29_Click:
    Exit Sub
Err_Command29_Click:
    MsgBox Err.Description
    Resume Exit_Command29_Click
End Sub

-dK
 
Thanks both for your help

Had problems getting it to pick up the default value so just adpated Pauls code

Thanks again
 

Users who are viewing this thread

Back
Top Bottom