I have created a form with an unbound subform. I am populating the subform with a form query. The query is changed based off the data selected on the main form. Example... I select value 123 on frmMain, this value is updated as criteria in the subform query. Once this subform query is updated I issue the code:
This of course does not refresh the subform. I have also tried the below pieces of code to no avail:
Me.Parent!frmMain!frmKeywordSub.Requery 'Refer to parent form
Me.Parent!frmMain!frmKeywordSub.Repaint 'Repaint the subform
Can anyone give a suggestion is this is even possible to refresh/requery this form or if maybe my syntax is not correct.
I tried your statement and found the below does work:
The issue I am having still remains though. It appears the Requery is not the issue. It works after I sort the records on the SubForm. This is really wierd, but it seems I have to "prime" or "initilize" the subform to get it to work. Let me describe:
When the main form is first opened the subform is visible=false. I select my value on the mainform which changes the query for the subform, then I use a button to toggle the subform into view. It seems to not work until I right click on the form, sort the records as acending or decending, then when I move from selection to selection on the main form the subform requiries correctly each and every time.
Does anyone know what happens when I sort the records to make this functionality work? If I need to initilize the records how would I go about this?
That's odd. Sorting will result implicically to a requery.
The issue you encounter might be related to the visible property. Maybe the requery won't be performed when the form's not visible and the state is not correctly updated when you set it to visible. What I'd suggest is you set the recordsource of the subform to empy (make it unbound) and set it after the form is set to visible. Setting the recordsource will also result in an implicit requery. In what way are you modifying the recordsource of the subform? How do you set the recordsource of the subform currently?
This is one of those things that you just go, DOH!
My query issued to populate the subform did not have an order by command. I added the order by to my query and shebang, it works!
Apparently, Access needs the order by to make the initial requery of the form. This fix will work for my purposes since I needed to order my returned values anyway, but if anyone can explain this qwirk, please indulge me.