Can't Requery, but can F9. What's going wrong?

E

efandango

I have a subform that I want to requery, but whatver I try doesn't work with
the code below: But if I manually press F9, the form will requery.

I have had to restort to putting the SendKeys "{F9}" into the code which
will make the form do the required requery.

Can someone tell me what I am doing wrong?

My Code:

Private Sub btn_Reset_Run_Reveal_List_Click()

CurrentDb.Execute "DELETE * FROM tbl_Run_Reveal_Target"
DoCmd.OpenQuery "Qry_Run_Reveal_Selector_Delete"
DoCmd.OpenQuery "Qry_Run_Reveal_Selector"

Forms![frm_Runs].[frm_Run_Reveal_Target].SetFocus
Forms![frm_Runs].[frm_Run_Reveal_Target].Form.[Run_waypoint].SetFocus
Me.Run_waypoint.Requery

SendKeys "{F9}"

Me.Requery

End Sub
 
S

Stuart McCall

efandango said:
I have a subform that I want to requery, but whatver I try doesn't work
with
the code below: But if I manually press F9, the form will requery.

I have had to restort to putting the SendKeys "{F9}" into the code which
will make the form do the required requery.

Can someone tell me what I am doing wrong?

My Code:

Private Sub btn_Reset_Run_Reveal_List_Click()

CurrentDb.Execute "DELETE * FROM tbl_Run_Reveal_Target"
DoCmd.OpenQuery "Qry_Run_Reveal_Selector_Delete"
DoCmd.OpenQuery "Qry_Run_Reveal_Selector"

Forms![frm_Runs].[frm_Run_Reveal_Target].SetFocus
Forms![frm_Runs].[frm_Run_Reveal_Target].Form.[Run_waypoint].SetFocus
Me.Run_waypoint.Requery

SendKeys "{F9}"

Me.Requery

End Sub

If Forms![frm_Runs].[frm_Run_Reveal_Target] is a subform control (looks like
it), you need to use:

Forms![frm_Runs].[frm_Run_Reveal_Target].Form.ReQuery
 
E

efandango

Stuart,

I tried the (your) same solution earlier, and that doesn't work either. I'm
really stumped as to why the F9 does the job, but not code?


Stuart McCall said:
efandango said:
I have a subform that I want to requery, but whatver I try doesn't work
with
the code below: But if I manually press F9, the form will requery.

I have had to restort to putting the SendKeys "{F9}" into the code which
will make the form do the required requery.

Can someone tell me what I am doing wrong?

My Code:

Private Sub btn_Reset_Run_Reveal_List_Click()

CurrentDb.Execute "DELETE * FROM tbl_Run_Reveal_Target"
DoCmd.OpenQuery "Qry_Run_Reveal_Selector_Delete"
DoCmd.OpenQuery "Qry_Run_Reveal_Selector"

Forms![frm_Runs].[frm_Run_Reveal_Target].SetFocus
Forms![frm_Runs].[frm_Run_Reveal_Target].Form.[Run_waypoint].SetFocus
Me.Run_waypoint.Requery

SendKeys "{F9}"

Me.Requery

End Sub

If Forms![frm_Runs].[frm_Run_Reveal_Target] is a subform control (looks like
it), you need to use:

Forms![frm_Runs].[frm_Run_Reveal_Target].Form.ReQuery
 
D

Douglas J. Steele

Stuart McCall said:
If Forms![frm_Runs].[frm_Run_Reveal_Target] is a subform control (looks
like it), you need to use:

Forms![frm_Runs].[frm_Run_Reveal_Target].Form.ReQuery

Actually, if he's trying to requery control Run_waypoint on the subform, he
needs to use

Forms![frm_Runs].[frm_Run_Reveal_Target].Form.[Run_waypoint].Requery
 
S

Stuart McCall

Douglas J. Steele said:
Stuart McCall said:
If Forms![frm_Runs].[frm_Run_Reveal_Target] is a subform control (looks
like it), you need to use:

Forms![frm_Runs].[frm_Run_Reveal_Target].Form.ReQuery

Actually, if he's trying to requery control Run_waypoint on the subform,
he needs to use

Forms![frm_Runs].[frm_Run_Reveal_Target].Form.[Run_waypoint].Requery

Yes, some abiguity in the first post:

"I have a subform that I want to requery"

then later:

"Me.Run_waypoint.Requery"

Let's see if your intuition has it right...
 

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

Top