Error 2467 in Access 2007

F

Finance guy

I am receiving Error 2467: The expression you entered refers to an object
that is closed or doesn't exist.

This is the line of offending code:
ls_dynamic_sql = subfrm_Project_Whatif_grid.Form.RecordSource

subfrm_Project_Whatif_grid is a sub form.

Is there anyway I can ensure that the subform is always open, or check if it
is open and open it if it is not open?

This is an app I just inherited that worked fine in Access 2003.

ANy assistance is appreciated.
 
A

Allen Browne

The simplest way to do this would be to go the other direction.

Save the subform's RecordSource as a query -- say Query1.
Then:
ls_dynamic_sql = Currentdb.QueryDefs("Query1").SQL

If you need to modify the RecordSource at some point, just change the SQL
property of the QueryDef and Requery the form.
 
F

Finance guy

Allen Browne said:
The simplest way to do this would be to go the other direction.

Save the subform's RecordSource as a query -- say Query1.
Then:
ls_dynamic_sql = Currentdb.QueryDefs("Query1").SQL

If you need to modify the RecordSource at some point, just change the SQL
property of the QueryDef and Requery the form.

I did that. When I requery the form, I get the error 2467 "The expression
you entered refers to an object that is closed or doesn't exist." However,
if I type
Debug.Print subfrm_Project_Whatif_grid.Visible it returns true. This is a
difficult one to figure out.
 
A

Allen Browne

Make sure you have a control for every field you need to refer to in your
code. Make sure none of the fields disappear or change data type.
 

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