G
GodotIsDead
I have a main form (frmMain) with a tab control. The tab control has
several pages, each with a subform which in turn may contain further
subforms. The page relating to patient assessment contains subform
fsub4Assessment. This in turn contains subform
fsub4AssessmentTechnologyAndDevices.
When I open frmMain I am getting an error from
fsub4AssessmentTechnologyAndDevices' Form_Current event, namely:
Error 2424: The expression you entered has a field, control, or
property name that Microsoft Office Access can't find.
The code for this event is:
Private Sub Form_Current()
On Error GoTo Err_Form_Current
'Take care of subform Current event firing when Parent!
[ReferralID] is null as parent record is created/deleted
If Not IsNull(Me.Parent![ReferralID]) Then
'If there is a medical and technology device need of 'Other'
then enable the comment box.
'Otherwise empty and disable the comment box.
If DCount("ReferralID", "tblAssessmentTechnologyAndDevices",
"TechnologyOrDevice = " & DLookup("TechnologyCode",
"tlkpTechnologyAndDevices", "TechnologyDesc = 'Other'") & " And
ReferralID = " & Me.Parent![ReferralID]) > 0 Then
Me.Parent!AssessmentTechnologyDevicesComment.Enabled =
True
Else
If Me.Parent!AssessmentTechnologyDevicesComment.Enabled
Then
If Me.Parent!AssessmentTechnologyDevicesComment.Value
<> "" Then '<<<<Code fails on this line during second pass (see below)
Me.Parent!AssessmentTechnologyDevicesComment.Value
= ""
End If
Me.Parent!AssessmentTechnologyDevicesComment.Enabled =
False
End If
End If
End If
Exit_Form_Current:
Exit Sub
Err_Form_Current:
Call LogError(Err.Number, Err.Description,
"fsub4AssessmentTechnologyAndDevices_Form_Current()")
Resume Exit_Form_Current
End Sub
Stepping through the code surprised me in two ways and I hope someone
can enlighten me on either point.
1. The event code fired twice. I expected it would only fire once
with the loading of the lowest level subform. What might be going on,
I wonder, to kick it off again?
2. The watch window information indicated, to my mind, a paradox. The
values below were as I expected during the first time the event
fired. However, during the second event there seemed to be a
contradiction in the meaning of the Me keyword. Its name indicates
that it is now frmMain (which came as a big surprise), whilst
Me.Parent!AssessmentTechnologyDevicesComment.Enabled still remained
'True' (as expected by me since AssessmentTechnologyDevicesComment is
a control on fsub4Assessment). If Me really is frmMain at this point
why was there no error to say that Me.Parent!
AssessmentTechnologyDevicesComment.Enabled referred to a control that
couldn't be found on the line before the one that appeared to be the
source of failure?
Expression Value Context
First pass:
Me.Parent!AssessmentTechnologyDevicesComment.Enabled True
Form_fsub4AssessmentTechnologyAndDevices.Form_Current
Me.Parent!AssessmentTechnologyDevicesComment.Value ""
Form_fsub4AssessmentTechnologyAndDevices.Form_Current
Me.Parent.Name "fsub4Assessment"
Form_fsub4AssessmentTechnologyAndDevices.Form_Current
Second pass:
Me.Parent!AssessmentTechnologyDevicesComment.Enabled True
Form_fsub4AssessmentTechnologyAndDevices.Form_Current
Me.Parent!AssessmentTechnologyDevicesComment.Value <The expression
you ... Form_fsub4AssessmentTechnologyAndDevices.Form_Current
Me.Parent.Name "frmMain"
Form_fsub4AssessmentTechnologyAndDevices.Form_Current
I am in a quagmire of my own making but can't see a way out! I would
appreciate some help and I hope someone may be able to throw some
light on this.
several pages, each with a subform which in turn may contain further
subforms. The page relating to patient assessment contains subform
fsub4Assessment. This in turn contains subform
fsub4AssessmentTechnologyAndDevices.
When I open frmMain I am getting an error from
fsub4AssessmentTechnologyAndDevices' Form_Current event, namely:
Error 2424: The expression you entered has a field, control, or
property name that Microsoft Office Access can't find.
The code for this event is:
Private Sub Form_Current()
On Error GoTo Err_Form_Current
'Take care of subform Current event firing when Parent!
[ReferralID] is null as parent record is created/deleted
If Not IsNull(Me.Parent![ReferralID]) Then
'If there is a medical and technology device need of 'Other'
then enable the comment box.
'Otherwise empty and disable the comment box.
If DCount("ReferralID", "tblAssessmentTechnologyAndDevices",
"TechnologyOrDevice = " & DLookup("TechnologyCode",
"tlkpTechnologyAndDevices", "TechnologyDesc = 'Other'") & " And
ReferralID = " & Me.Parent![ReferralID]) > 0 Then
Me.Parent!AssessmentTechnologyDevicesComment.Enabled =
True
Else
If Me.Parent!AssessmentTechnologyDevicesComment.Enabled
Then
If Me.Parent!AssessmentTechnologyDevicesComment.Value
<> "" Then '<<<<Code fails on this line during second pass (see below)
Me.Parent!AssessmentTechnologyDevicesComment.Value
= ""
End If
Me.Parent!AssessmentTechnologyDevicesComment.Enabled =
False
End If
End If
End If
Exit_Form_Current:
Exit Sub
Err_Form_Current:
Call LogError(Err.Number, Err.Description,
"fsub4AssessmentTechnologyAndDevices_Form_Current()")
Resume Exit_Form_Current
End Sub
Stepping through the code surprised me in two ways and I hope someone
can enlighten me on either point.
1. The event code fired twice. I expected it would only fire once
with the loading of the lowest level subform. What might be going on,
I wonder, to kick it off again?
2. The watch window information indicated, to my mind, a paradox. The
values below were as I expected during the first time the event
fired. However, during the second event there seemed to be a
contradiction in the meaning of the Me keyword. Its name indicates
that it is now frmMain (which came as a big surprise), whilst
Me.Parent!AssessmentTechnologyDevicesComment.Enabled still remained
'True' (as expected by me since AssessmentTechnologyDevicesComment is
a control on fsub4Assessment). If Me really is frmMain at this point
why was there no error to say that Me.Parent!
AssessmentTechnologyDevicesComment.Enabled referred to a control that
couldn't be found on the line before the one that appeared to be the
source of failure?
Expression Value Context
First pass:
Me.Parent!AssessmentTechnologyDevicesComment.Enabled True
Form_fsub4AssessmentTechnologyAndDevices.Form_Current
Me.Parent!AssessmentTechnologyDevicesComment.Value ""
Form_fsub4AssessmentTechnologyAndDevices.Form_Current
Me.Parent.Name "fsub4Assessment"
Form_fsub4AssessmentTechnologyAndDevices.Form_Current
Second pass:
Me.Parent!AssessmentTechnologyDevicesComment.Enabled True
Form_fsub4AssessmentTechnologyAndDevices.Form_Current
Me.Parent!AssessmentTechnologyDevicesComment.Value <The expression
you ... Form_fsub4AssessmentTechnologyAndDevices.Form_Current
Me.Parent.Name "frmMain"
Form_fsub4AssessmentTechnologyAndDevices.Form_Current
I am in a quagmire of my own making but can't see a way out! I would
appreciate some help and I hope someone may be able to throw some
light on this.