Changing a value on a parent form from values on a subform

G

Guest

I'm attempting to change the status of a record on the main form to "Closed"
based on two values entered on a continuous subform. Here's the code, which
is generating a "recordset not updateable" error.

If Me.[cboDPAction] = "Installation Completed" And Not
(IsNull(Me.[dtCompleteDate])) Then
Me.Parent.[txtStatus] = "Closed"
End If
I have this code in the AfterUpdate event of the subform.
Does anyone have a suggestion? Should the event be initiated from the parent
form?
 
J

Jeff L

A subform does not have an AfterUpdate event. It would have to be a
field on your subform. Instead of the Me.Parent, try
Forms!MainFormName!txtStatus = "Closed"

Hope that helps!
 
V

Van T. Dinh

Subforms (they are Forms, after all) do have Form_AfterUpdate Event, Jeff.

--
HTH
Van T. Dinh
MVP (Access)



Jeff L said:
A subform does not have an AfterUpdate event. It would have to be a
field on your subform. Instead of the Me.Parent, try
Forms!MainFormName!txtStatus = "Closed"

Hope that helps!


Susan said:
I'm attempting to change the status of a record on the main form to
"Closed"
based on two values entered on a continuous subform. Here's the code,
which
is generating a "recordset not updateable" error.

If Me.[cboDPAction] = "Installation Completed" And Not
(IsNull(Me.[dtCompleteDate])) Then
Me.Parent.[txtStatus] = "Closed"
End If
I have this code in the AfterUpdate event of the subform.
Does anyone have a suggestion? Should the event be initiated from the
parent
form?
 
V

Van T. Dinh

Check that the RecordSource of the parent Form is updatable ...

If it is, check the "Recordset Type" Property (should not be "Snapshot") and
the AllowEdits Property.
 
G

Guest

Yes, it does have an AfterUpdate. I tried the suggested syntax and it's still
not working.

(PS: The source of the problem "recordset not updateable" is another issue
that I'm working on.)
--
susan


Van T. Dinh said:
Subforms (they are Forms, after all) do have Form_AfterUpdate Event, Jeff.

--
HTH
Van T. Dinh
MVP (Access)



Jeff L said:
A subform does not have an AfterUpdate event. It would have to be a
field on your subform. Instead of the Me.Parent, try
Forms!MainFormName!txtStatus = "Closed"

Hope that helps!


Susan said:
I'm attempting to change the status of a record on the main form to
"Closed"
based on two values entered on a continuous subform. Here's the code,
which
is generating a "recordset not updateable" error.

If Me.[cboDPAction] = "Installation Completed" And Not
(IsNull(Me.[dtCompleteDate])) Then
Me.Parent.[txtStatus] = "Closed"
End If
I have this code in the AfterUpdate event of the subform.
Does anyone have a suggestion? Should the event be initiated from the
parent
form?
 
V

Van T. Dinh

If the Recordset is not updatable, you cannot change the value of bound
Controls when the Form is bound to a non-updatable Recordset. Thus, if you
fix up the Recordset, I think your code will work ...
 
G

Guest

Thanks Van. I fixed the problem with the recordset and it worked just fine.
--
susan


Van T. Dinh said:
Check that the RecordSource of the parent Form is updatable ...

If it is, check the "Recordset Type" Property (should not be "Snapshot") and
the AllowEdits Property.

--
HTH
Van T. Dinh
MVP (Access)



Susan L said:
I'm attempting to change the status of a record on the main form to
"Closed"
based on two values entered on a continuous subform. Here's the code,
which
is generating a "recordset not updateable" error.

If Me.[cboDPAction] = "Installation Completed" And Not
(IsNull(Me.[dtCompleteDate])) Then
Me.Parent.[txtStatus] = "Closed"
End If
I have this code in the AfterUpdate event of the subform.
Does anyone have a suggestion? Should the event be initiated from the
parent
form?
 
G

Guest

What kind of problem with a recordset would cause this behavior? I have a
database that worked just fine, then I had some corrupt records, did a
compact and repair, deleted the corrupt records, then pasted the records back
in from a backup, and now I get the recordset is not updateable error message
when I open the form. I tried exporting the form from a version of the
database that worked, and I still get the error message.


Susan L said:
Thanks Van. I fixed the problem with the recordset and it worked just fine.
--
susan


Van T. Dinh said:
Check that the RecordSource of the parent Form is updatable ...

If it is, check the "Recordset Type" Property (should not be "Snapshot") and
the AllowEdits Property.

--
HTH
Van T. Dinh
MVP (Access)



Susan L said:
I'm attempting to change the status of a record on the main form to
"Closed"
based on two values entered on a continuous subform. Here's the code,
which
is generating a "recordset not updateable" error.

If Me.[cboDPAction] = "Installation Completed" And Not
(IsNull(Me.[dtCompleteDate])) Then
Me.Parent.[txtStatus] = "Closed"
End If
I have this code in the AfterUpdate event of the subform.
Does anyone have a suggestion? Should the event be initiated from the
parent
form?
 

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