Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Close a form only if a field in another form is NOT null

Status
Not open for further replies.

Hulm1

Technical User
Mar 11, 2008
100
GB
Just to confirm the correct form structure

1) Main Form "Job_Edit"
2) Subform "Job_Edit_JobTask_List (contains a look-up for all the tasks in the table zmtTasks). It is a continuous form. Each record also has a check box which has an onclick event. This onclick event as follows:

Private Sub chkEdit_Click()

Dim sWhere$

Me.chkEdit = False
DoCmd.RunCommand acCmdSaveRecord

Me.RecordsetClone.Bookmark = Me.Bookmark
sWhere$ = "JobTaskID = " & Me.RecordsetClone("JobTaskID")
DoCmd.OpenForm "JobTask_Edit", , , sWhere$, , acDialog, Me.Parent.Name

End Sub

This opens the following form

3) JobTask_Edit. This has a subform
4) subform JobTask_Edit_JobSubTask_List. This is similar to form 2 (above) but looks up a list of subtasks from the table zmtSubTask.

And so the question. Every Task in Form 2, should have a least one subtask connected to it in form 4. If not, I want it to be impossible to close Form 1 and for a message to pop up and say why!

I hope you understand!!

I should be clear that the above database was developed by a another. I am learning by leaps and bounds but I could not have developed the above layout. I say that my abilities are not overestimated for any replies. I need a fairly clear blow by blow explanation how to do that complete with code examples if that is not too much to ask.


Thanks
 
Actually, it looks like the problem is caused by the Iif() function in the ControlSource of textbox CountOfSubTasks setting the field to an empty string (""). Change it to Null instead:

[tt]=Iif(Not IsNull(JobTaskID),
DCount("JobSubTaskID","JobSubTask","JobTaskID=" & JobTaskID), Null)[/tt]

The 2 display textboxes couldn't evaluate > or = against the empty string. They work OK if evaluating against a Null value however.

Max Hugen
Australia
 
That's done it! Thanks very very much!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top