Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 598
  • Last Modified:

Requery an Open Query from a Form, Use Isloaded to test if Query is already open

I have a simple form with an unbound text box and a button that opens a calendar form.  The user selects the date from the pop-up calendar and it is entered into the textbox.  There is a query that uses the date from that unbound textbox as part of a calculated field that uses the iPmt Function.

I have a number of problems based on what I am trying to do with the above.

1)  When I change the date in the textbox using the pop-up calendar, it does not trigger the afterupdate event of the textbox.

2)  If the query isn't already open, I would like to open the query after the textbox has been updated. (Can't make isloaded with a query work)

3)  If the query is already open, I would like it to "requery" (I can't seem to make that happen based on the afterupdate event of the unbound textbox not triggering).  If that is not possible, I would like to test for the query already being open, close it, and open it again. (isloaded?)

I have plenty more issues, but this will get me started.  I have searched the EE for Requery info, and found some, but didn't answer my questions.  I really would like to know how to use IsLoaded with a query, and be able to requery an open query if possible.

Below was my attempt at isloaded, based on help files etc.  I am afraid I am just plain lost here.

If CurrentData.AllQueries(qryIntDue).IsLoaded = False Then
'DoCmd.OpenQuery "qryIntDue"
MsgBox "Hi"
Else
MsgBox "Bye"
End If

When I tried the above, it tested as false whether or not the query was open.

Thanks for any help that can be given.

Hubbs
0
Hubbsjp21
Asked:
Hubbsjp21
  • 3
  • 2
3 Solutions
 
jerryb30Commented:
Maybe:
If CurrentData.AllQueries("qryIntDue").IsLoaded = False Then
0
 
GRayLCommented:
Jerry is telling you that you omitted the double quotes around the query name.
0
 
jerryb30Commented:
Without telling you...:>)
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
Hubbsjp21Author Commented:
Okay . . . . the quotes solved that issue rather quickly.  It makes me feel a little better that I was at least on the right track . . .   THANKS!

What about requerying an open query (now that I can determine it is open) from that form that has the button.  Can that be done?

Any ideas on why the afterupdate tigger might not be working?
0
 
jerryb30Commented:
If we are talking about a datasheet view of a query,  do not think it can be done. I suspect requery does the same thing-Closes and opens the query which is the recordsource of a form. Otherwise, there would be a Refresh option in a query window. It just happens so fast, sometimes, you just do not notice. But I do not have access to resources at home to check.
0
 
GRayLCommented:
One cannot refresh or re-query a Query that is open.  It has to be closed and re-run.
0

Featured Post

Veeam and MySQL: How to Perform Backup & Recovery

MySQL and the MariaDB variant are among the most used databases in Linux environments, and many critical applications support their data on them. Watch this recorded webinar to find out how Veeam Backup & Replication allows you to get consistent backups of MySQL databases.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now