Link to home
Start Free TrialLog in
Avatar of ouestque
ouestqueFlag for United States of America

asked on

Access:Refresh my subforrm: Is not working

My database has the following:
2 forms titled form1 and sub_form2
2 queries titled sortbyfirstname, sortbylastname
1 table titled Names

 On form1 there is subform2 two optionboxes(optionbox1 and optionbox2)

 When a user chooses optionbox1 then it runs the following code:
[Forms]![sub_form2].RecordSource = "sortbyfirstname"

When a user chooses optionbox2 then it runs the following code:
[Forms]![sub_form2].RecordSource = "sortbylastname"


When I open both forms, I notice that the above code changes subform2, but form1 there is no change. I have tried docmd.requery sub_form2 but the subform in form 1 does not change. Does anyone know why. Can anyone help me figure out what to do to make the subform refresh when its recordsource is changed?
SOLUTION
Avatar of adraughn
adraughn
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I think you're confusing referencing forms and subforms. When you're wanting to reference the subform you *must* reference it via it's parent.

If I understand your post correctly, what happens is you open both form 1 with the subform2 on it, and also the subform2-on-it's-own. When you click your button, only the subform2-on-it's-own is getting updated, but it's the subform on form1 you're wanting to update?

adraughn's correction correctly references the subform2 on the main form1. If you just change your [Forms]![sub_form2].RecordSource = "sortbyfirstname"
...to...
me.sub_form2.RecordSource = "sortbyfirstname"
... then you should see the subform updating, but the subform2-opened-on-it's-own no longer refreshing.

HTH,

Justin
Avatar of ouestque

ASKER

Here are the details for the subform on form1: Name=sub_form and Source Object=sub_form2

I have tried swampy's idea above but I get the following error: "Method or data member not found."

Here is what I am using: me.sub_form2.RecordSource = "sortbyfirstname"

I thought maybe the error is that I am referring to sub_form2, instead of the name of the subform on form1 so I tried the following and got the same error: me.sub_form.RecordSource = "sortbyfirstname"

Ya'll have any ideas?
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial