Solved

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

Posted on 2007-12-06
6
565 Views
Last Modified: 2008-02-01
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
Comment
Question by:Hubbsjp21
  • 3
  • 2
6 Comments
 
LVL 26

Accepted Solution

by:
jerryb30 earned 450 total points
Comment Utility
Maybe:
If CurrentData.AllQueries("qryIntDue").IsLoaded = False Then
0
 
LVL 44

Expert Comment

by:GRayL
Comment Utility
Jerry is telling you that you omitted the double quotes around the query name.
0
 
LVL 26

Expert Comment

by:jerryb30
Comment Utility
Without telling you...:>)
0
Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 

Author Comment

by:Hubbsjp21
Comment Utility
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
 
LVL 26

Assisted Solution

by:jerryb30
jerryb30 earned 450 total points
Comment Utility
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
 
LVL 44

Assisted Solution

by:GRayL
GRayL earned 50 total points
Comment Utility
One cannot refresh or re-query a Query that is open.  It has to be closed and re-run.
0

Featured Post

Get up to 2TB FREE CLOUD per backup license!

An exclusive Black Friday offer just for Expert Exchange audience! Buy any of our top-rated backup solutions & get up to 2TB free cloud per system! Perform local & cloud backup in the same step, and restore instantly—anytime, anywhere. Grab this deal now before it disappears!

Join & Write a Comment

I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now