verify data on forms subform

oxicottin

Learning by pecking away....
Local time
Today, 18:34
Joined
Jun 26, 2007
Messages
888
Hello, I have a form named "AccidentEntry" and on this form is a subform named "AccidentEntrySubForm". I have a button on the AccidentEntry Form that I need to verify that data is in a text box named "txtRootCause" on my subform before calling a procedure. what is wrong in my code because its going to the procedure then the text field is blank and its suposed to give a msg box and set focuse to the text box on my subform.

Code:
Private Function VerifyEmailData()
   
   If Forms("AccidentEntry")("AccidentEntrySubForm").Form.txtRootCause = "" Then
      MsgBox "You Must enter a Root Cause before proceeding! ", vbCritical, "Selection Error"

      Forms("AccidentEntry")("AccidentEntrySubForm").Form.txtRootCause.SetFocus

     Exit Function
  Else
     Call EmailData
  End If
End Function
 
I have already looked there and tried.
Code:
Private Function VerifyEmailData()
   
   If Me.AccidentEntrySubform.Form!txtRootCause = "" Then
      MsgBox "You Must enter a Root Cause before proceeding! ", vbCritical, "Selection Error"

      Me.AccidentEntrySubform.Form!txtRootCause.SetFocus

     Exit Function
  Else
     Call EmailData
  End If
End Function
with the same results. Any Ideas?

Thanks!
 
In the if statemetn I usually put the following to cater for a null field. At the moment you are looking at an empty string only:

Code:
If Me.AccidentEntrySubform.Form!txtRootCause = "" or isnull(Me.AccidentEntrySubform.Form!txtRootCause) Then
 
Thank god that was it.... :D Thank you!
 

Users who are viewing this thread

Back
Top Bottom