Solved

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

Posted on 2007-12-06
6
572 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
ID: 20422844
Maybe:
If CurrentData.AllQueries("qryIntDue").IsLoaded = False Then
0
 
LVL 44

Expert Comment

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

Expert Comment

by:jerryb30
ID: 20422990
Without telling you...:>)
0
Ransomware: The New Cyber Threat & How to Stop It

This infographic explains ransomware, type of malware that blocks access to your files or your systems and holds them hostage until a ransom is paid. It also examines the different types of ransomware and explains what you can do to thwart this sinister online threat.  

 

Author Comment

by:Hubbsjp21
ID: 20423887
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
ID: 20424323
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
ID: 20424812
One cannot refresh or re-query a Query that is open.  It has to be closed and re-run.
0

Featured Post

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Most if not all databases provide tools to filter data; even simple mail-merge programs might offer basic filtering capabilities. This is so important that, although Access has many built-in features to help the user in this task, developers often n…
I originally created this report in Crystal Reports 2008 where there is an option to underlay sections. I initially came across the problem in Access Reports where I was unable to run my border lines down through the entire page as I was using the P…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…

803 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