Subform Refresh Fails on Opening Form. Works Otherwise.

H

HumanJHawkins

Hi,

I have two subforms on a main form. One subform must refresh the other
after any update or delete, so I put a refresh command in the
"OnCurrent" event. This works great except when I first open the form.
I get "Run-time error '2455': You entered an expression that has an
invalid reference to the property Form/Report."

I suspect this is because the subform being refreshed is not yet
initialized, etc. Can someone help me figure out how to test for
whether a form/subform is ready to be refreshed yet, so I can just
skip the refresh the first time. (Or to test if the
"Parent.<SubformName>" reference is valid.

FYI, I could put the refresh elsewhere, such as "after update" however
that doesn't handle deletes. And for some reason, "After Delete
Confirm" doesn't appear to fire... When I put the refresh there,
nothing happens. So "OnCurrent" seems like the best place to put this.

Thanks in advance for any help!
 
J

Jeanette Cunningham

Hi HumanJHawkins,
If you are letting the delete happen by selecting the row and hitting
delete, you can get the before del confirm and after del confirm to fire by
turning the access option on for confirm record changes. That way you can
avoid using the current event.

Maybe you can try the current code and trap for the error using code below
in the error handling section of the current sub.

If Err.Number = 2455 Then
On error Resume Next


Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia
 
S

Stuart McCall

Jeanette Cunningham said:
Hi HumanJHawkins,
If you are letting the delete happen by selecting the row and hitting
delete, you can get the before del confirm and after del confirm to fire
by turning the access option on for confirm record changes. That way you
can avoid using the current event.
<snip>

Jeanette

The option is 'Document Deletions' in the Access UI, and in code:

Application.SetOption "Confirm Document Deletions", True
 
J

Jeanette Cunningham

Thanks Stuart


Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia
 

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

Similar Threads


Top