Subform - how to change recordset values from pop up....

Z

ZRexRider

Hi,

Logically I believe this should work and actually, sometimes it does
but there must be something "illegal" about what I'm doing because it
eventually crashes MS-Access (2003 SP1)

In a nutshell - I have a control on a line item of a sub-form that is a
continuous form. If there are 15 line items then there will be 15
controls. If user clicks - I popup modal form to request additional
information that I want to write back to a text field in the recordset
at the row where the control was clicked.

Seems straightforward and by golly it actually works sometimes (just to
tease me). However very soon I get the ugly "Access is crashing please
let me tell Bill Gates what went wrong message". This happens
executing the exact same line of code:

Forms!frmMainForm.frmSubForm.Form.Recordset("txtFieldToUpdate").Value =
strDataToUpdateFieldWith

Logically that line updates a the current record set / line item on the
form that called it and when it works it does exactly what you would
expect. Once it fails, it fails catastrophically every time it hits
that line - if i comment out the line, Access stops failing.

Soo... is it a bad thing to update a record set on a sub-form from
another modal form? This is what bugs me about developing in Access.
There are errors that get presented through the error object and then
there are those errors that shut down Access and have no logic.

Any ideas - I'm stumped?
 
Z

ZRexRider

More info -

Once the above error occurs, every time you try to open the pop form
that caused the error Access Catastrophically fails. However, if I
open up the application and simply open any module in VBA, make no
changes, save the changes and start the application - the
form/subform/pop form scenario works until the next catastrophic
failure.

So - it seems that this valid syntax eventually corrupts the Access ADP
file's form and for some reason - re-saving ANYTHING fixes it
temporarily.

What the heck?
 
Z

ZRexRider

Here's the answer - just in case somebody else ever tries to do what I
did and get's the same results:

Instead of trying to update the sub-form's recordset directly like
this:

Forms!frmMainForm.frmSubForm.Form.Recordset("txtFieldToUpdate").Value =
strDataToUpdateFieldWith

I was given a tip to try just updating the subform field and let it
take care of the recordset like this:

Forms!frmMainForm.frmSubForm.Form("txtFieldToUpdate") =
strDataToUpdateFieldWith

I still think the first syntax should have worked (it did sometimes)
and it certainly shouldn't have crashed Access.

Thanks to Graham Mandeno [Access MVP] of Auckland New Zealand - I'm
moving forward!
 
Top