Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Changing Recordsource on a subform... 1

Status
Not open for further replies.

MSMINNICH

Programmer
Oct 3, 2001
33
US
This is strange...
I have a form with a subform. On the button for next record on the main form, I have code to change the recordsource of the subform. The code executes, and in the immediate window I can see the proper recordsource for the subform. The problem is, that the proper records don't show up. I cut the subject recordsource out of the immediate window and... lo and behold, I get the proper records. I then right clicked on the subform and remove all filters and the records show up fine. I added the line Forms!myform.mysub.form.filteron = false and still no luck. There is no filter in design mode... I'm stuck...
Thanks,
Scott
 
Access is supposed to requery the record source for a subform when it changes, but I've found this doesn't always occur. After changing the record source insert a requery command:

Me!MainForm!Subform.Requery

and see if that gets the job done.


Cheers,

Uncle Jack
 
OK, I did that. But still no luck. Perhaps it's my syntax... Instead of
Me!MainForm!Subform.Requery
I have
Me!Subform.Requery
 
It shouldn't make any difference whether you use the Me operator or the name of the subform. I'd still try it in the Forms!MainFormName!SubformName.Requery format just to make sure. (I just noticed that my suggested syntax was itself wrong - It should have been as suggested in here without the Me.) I suspect it's something to do with the filters feature. I never use them so I'm not very good at trouble shooting problems that may result.

Uncle Jack
 
Jack-
Thanks. I learned something today. Get this...
Me!subform.requery causes the problem, but no syntax error or anything. Me!subform.form.requery works. Knowing enough C++ to be dangerous, I wonder if Me!subform.requery refoers to the extender object of the activex object that is the subform. I've always wanted to know about those internals...
Thanks again.
Scott
 
I've noticed that sometimes the Forms!Main!Sub.requery works and sometimes I have to use Forms!Main!sub.Form.Requery. I don't know why one format has to be used in one case and the other in other cases, but I can testify that that's the case. As long as you've got it going I suppose it doesn't really matter.

Cheers,

Uncle Jack
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top