ouestque
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].Record Source = "sortbyfirstname"
When a user chooses optionbox2 then it runs the following code:
[Forms]![sub_form2].Record Source = "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?
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].Record
When a user chooses optionbox2 then it runs the following code:
[Forms]![sub_form2].Record
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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?
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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].Record
...to...
me.sub_form2.RecordSource = "sortbyfirstname"
... then you should see the subform updating, but the subform2-opened-on-it's-ow
HTH,
Justin