I have built an Action Item database that has a form where you can close out the Action Item by putting a date complete. Before you are allowed to put in the Action Item date complete, I have the code below to check to make sure all subtasks are completed. If they are not completed you get a message box telling you to close out all subtasks before closing out the Action Item.
The problem is that if I have a subform that does not have any records (i.e., there are no subtask assigned to the Action Item), I need to ignore the code (i.e., do not check to make sure all subtask are closed) and allow a date to be entered into the Aciton Item completed field.
Currently I get an error becasue the subtasks (subform) are not all closed becasue there are no records in the subform.
Below is the code I currently have in my form. Thanks in advance for the help.
__________ Code in Mainform's Selection Change - Event Property Sheet _____
Private Sub Form_SelectionChange()
Function AllCompleted() As Boolean
AllCompleted = True
With Me.[Subtask - Subform - Continous Form (2)].Form.RecordsetClone
Do Until .EOF
If VarType(![Actual Complete Date]) <> 7 Then
AllCompleted = False
___ Code in Mainform's text box for completed date - Before Update Property Sheet ____
Private Sub Actual_Complete_Date_BeforeUpdate(Cancel As Integer)
If Me.[Actual Complete Date] = "" Or IsNull([Actual Complete Date]) Then
Me.Completed = False
Me.Completed = True
If Not AllCompleted Then
MsgBox "There are Subtasks that are not completed. All Subtasks must be completed before an Action Item can be completed."
Cancel = True