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

  • Thread starter Thread starter efandango
  • Start date Start date
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
 
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
 
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
 
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
 
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...
 
Back
Top