Setting a value in a field in a subform to 'Reject' from an event

R

Robbhat

Hi friendly community..Please help me with the following. I have a form with
two subforms (Both in datasheet view):


Fo_Treatment_Course_Subform (referred to as FormB)
Fo_Treatment_Details_Subform(referred to as FormC)

C is linked to B (Master-child relationship) with B as the Master. Therefore
for each lineitem created in B, there will be multiple lineitems in C.

What I am trying to achive is the following.

On double-clicking on a field in B (ie a particular line item), I want to
set a field (Delete_Course) in that record (Line item) to the value "Reject"
on the following conditions:

1) There must be no lineitems that have been created in C ie
Treatment_Details_ID (autonumber) is null
2) If records have been created then if all such records have the field
Deleted_Treatment = "reject" (This is a similar field in C as in B and not
the same)
3) If any of the lineitems have had records created and there is one or more
fields with Deleted_Treatment = Null then MsgBox("Yoy cant delete this
course")


Here is my code but it doesnt work and hence I request assistance:

Private Sub Patient_ID_DblClick(Cancel As Integer)

If IsNull(Me.Treatment_Course_Start_Date) = True Then
MsgBox ("You cant delete a course that you have not started")
Exit Sub
End If


If IsNull(Me.Treatment_Course_Start_Date) = False Then
If Me.Parent.Fo_Treatment_Details_Subform.Dirty = False Then
Me.Deleted_Course = "Reject"
Exit Sub
End If
End If

If IsNull(Me.Treatment_Course_Start_Date) = False Then
If Me.Parent.Fo_Treatment_Details_Subform.Dirty = True Then
If IsNull(Me.Deleted_Course) = True Then
Me.Deleted_Course = "Reject"
Exit Sub
End If
End If
End If


If IsNull(Me.Treatment_Course_Start_Date) = False Then
If Me.Parent.Fo_Treatment_Details_Subform.Dirty = True Then
If IsNull(Me.Deleted_Course) = False Then
MsgBox ("You cant delete a course with associated treatment")
Exit Sub
End If
End If
End If



End Sub
 

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

Top