Changing a subform's record source: with 2003 not working any more

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

With ACCESS 2000 and ACCESS XP I could use the following code to dynamically
change the content of a subform, i.e. depending on what type of filter the
user had chosen in a combo box, I could feed the subform with different
content:

1 With Me.Controls("sfACT_SetFilters_Flt" & iFlt).Report
2 .RecordSource = szSQL
3 .Refresh
4 End With

Actually I don't know, what the report property in a form/subform stands for
(the help file mentions that this property exists, but not, what it's good
for, and why I can't access the RecordSource property directly) but it worked
reliably over years

In ACCESS 2003 I get the runtime error 2467 (the expression you entered
refers to an object that is closed or doen't exist). What's going wrong
there? What is so different in ACCESS 2003?
 
Jens Gollmer said:
With ACCESS 2000 and ACCESS XP I could use the following code to dynamically
change the content of a subform, i.e. depending on what type of filter the
user had chosen in a combo box, I could feed the subform with different
content:

1 With Me.Controls("sfACT_SetFilters_Flt" & iFlt).Report
2 .RecordSource = szSQL
3 .Refresh
4 End With

Actually I don't know, what the report property in a form/subform stands for
(the help file mentions that this property exists, but not, what it's good
for, and why I can't access the RecordSource property directly) but it worked
reliably over years

In ACCESS 2003 I get the runtime error 2467 (the expression you entered
refers to an object that is closed or doen't exist). What's going wrong
there? What is so different in ACCESS 2003?


I would never have expected that to work, but previous
versions were a little sloppy about that kind of thing. You
should be using the .Form property instead.

With Me.Controls("sfACT_SetFilters_Flt" & iFlt).FORM
.RecordSource = szSQL
End With

Note that setting the RecortdSource property automatically
performs a Requery so the Refresh is a waste of time.
 

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

Back
Top