I've recently been upgraded here at work from Access 97 to Access 2002. Since that happened, I've hit a problem with changing values in a subform, which in 97 worked fine.
The following code relates to a checkbox which displays the subform to allow data entry. The code handles the situation that if the checkbox is unchecked, all fields are cleared when the subform is made invisible. Unfortunately, in 2002 I get the message "Run-time error 2448: You can't assign a value to this object" when it gets to the row "frm.Form![FullT Occp] = False". This field is another checkbox.
If I manually remove entries from the fields in the subform all is fine. It's just in VBA it don't like it!
Any idease, please?
Private Sub Check69_Click()
Set frm = Me![PA Variable Parts B1 and B2]
If Check69.Value = True Then
frm.Visible = True
Else
If (frm.Form![FullT Occp] = False Or IsNull(frm.Form![FullT Occp])) And _
IsNull(frm.Form![Other Occp]) And _
(frm.Form![Semi Retd] = False Or IsNull(frm.Form![Semi Retd])) Then
frm.Visible = False
Else
If MsgBox("Unsetting Sole Practitioner flag will clear the Sole Practitioner record", _
vbExclamation + vbDefaultButton1 + vbOKCancel, _
"Warning - Sole Practitioner delete") = vbOK Then
frm.Form![FullT Occp] = False
frm.Form![Semi Retd] = False
frm.Form![Other Occp] = Null
frm.Visible = False
Else
Check69.Value = True
End If
End If
End If
End Sub
Steve House
shouse@icaew.co.uk
The following code relates to a checkbox which displays the subform to allow data entry. The code handles the situation that if the checkbox is unchecked, all fields are cleared when the subform is made invisible. Unfortunately, in 2002 I get the message "Run-time error 2448: You can't assign a value to this object" when it gets to the row "frm.Form![FullT Occp] = False". This field is another checkbox.
If I manually remove entries from the fields in the subform all is fine. It's just in VBA it don't like it!
Any idease, please?
Private Sub Check69_Click()
Set frm = Me![PA Variable Parts B1 and B2]
If Check69.Value = True Then
frm.Visible = True
Else
If (frm.Form![FullT Occp] = False Or IsNull(frm.Form![FullT Occp])) And _
IsNull(frm.Form![Other Occp]) And _
(frm.Form![Semi Retd] = False Or IsNull(frm.Form![Semi Retd])) Then
frm.Visible = False
Else
If MsgBox("Unsetting Sole Practitioner flag will clear the Sole Practitioner record", _
vbExclamation + vbDefaultButton1 + vbOKCancel, _
"Warning - Sole Practitioner delete") = vbOK Then
frm.Form![FullT Occp] = False
frm.Form![Semi Retd] = False
frm.Form![Other Occp] = Null
frm.Visible = False
Else
Check69.Value = True
End If
End If
End If
End Sub
Steve House
shouse@icaew.co.uk