Running Error Checks on SubForm

  • Thread starter Thread starter Rob
  • Start date Start date
R

Rob

I have a database that does a lot of checking to ensure that the proper data
is inserted in the proper fields. In this particular case, I am trying to
verify that if a box "Unacceptable" has been checked, that the user enters
the number of occurrences as well as a note as to why an Activity is
Unacceptable. I have the following code:

With Me.RecordsetClone

..MoveFirst


Do Until .EOF

If .[Unacceptable] = Yes = 0 And .[Occurrence] = 0 Then
MsgBox "You have checked Unacceptable for Activity # " &
Me.RecordsetClone.[Sequence] & "! Add the number of Occurrences!!", vbOKOnly,
"Occurrences?"


Exit Sub
End If


..MoveNext



Loop
End With




With Me.RecordsetClone
.MoveFirst
Do Until .EOF

If .[Unacceptable] = Yes = 0 And .[Notes] & "" = "" Then
MsgBox "You have checked Unacceptable for an Activity # " & .[Sequence]
& "! Add Explanation!!", vbOKOnly, "No Explanation"


Exit Sub
End If
.MoveNext
Loop
End With

End Sub

This works perfectly find for the Parent Form. However I have a subform
that needs to have the same checks and I can't figure out how to get the
program to access the subform control which is "ProcessChecklist" and to run
the same checks. Any help would be greatly appreciated.
 
You can use the form BeforeUpdate event to check if all the fields are filled
and prompt a message and stop the process.

Something like

If Me.[Unacceptable] = True And (Me.[Occurrence] = 0 Or
IsNull(Me.[Occurrence]) Then
MsgBox "You have checked Unacceptable for Activity # " &
Me.[Sequence] & "! Add the number of Occurrences!!", vbOKOnly, "Occurrences?"
Cancel = True ' Stop the process
End If

That way the user will be stoped before moving to another record
 

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

email from subform 8
Simple Loop Recordset Question 2
Share a form 1
Code error 4
Change Password 2
Assign recordset - subform 1
Do/Loop Dilemma 6
Loop inside a loop 6

Back
Top