Solved

Hiding queries when opened from dialog box

Posted on 2002-06-04
3
175 Views
Last Modified: 2008-03-06
How might you hide a query in code when it is being opened from the On Click event procedure?  I have a dialog box that passes parameters to 6 different queries and the query results are displayed in a report.  When the command button for the dialog box is clicked, all 6 queries open and then the report displaying the results.  Current code looks like this:

Private Sub cmdRunContribTransCountQry_Click()
On Error GoTo Err_cmdRunContribTransCountQry_Click

    DoCmd.OpenQuery "qryContribTransCount", acNormal, acEdit
    DoCmd.OpenQuery "qryDistribTransCount", acNormal, acEdit
    DoCmd.OpenQuery "qryLoansTransCount", acNormal, acEdit
    DoCmd.OpenQuery "qryContribElapsedAvg", acViewNormal, acEdit
    DoCmd.OpenQuery "qryDistribElapsedAvg", acViewNormal, acEdit
    DoCmd.OpenQuery "qryLoansElapsedAvg", acViewNormal, acEdit
    DoCmd.OpenReport "rptERScorecard", acViewPreview
           
Exit_cmdRunContribTransCountQry_Click:
    Exit Sub

Err_cmdRunContribTransCountQry_Click:
    MsgBox Err.Description
    Resume Exit_cmdRunContribTransCountQry_Click
   
End Sub

Any suggestions?
0
Comment
Question by:taraernst
  • 2
3 Comments
 
LVL 8

Accepted Solution

by:
dovholuk earned 100 total points
ID: 7054658
use currentdb.querydefs("YourQUery").execute instead...

i think that's what you're looking for...

if not let us know.

dovholuk
0
 
LVL 8

Expert Comment

by:dovholuk
ID: 7054663
further explained:

so your code looks like this:

Private Sub cmdRunContribTransCountQry_Click()
On Error GoTo Err_cmdRunContribTransCountQry_Click

   currentdb.querydefs("qryContribTransCount")
   currentdb.querydefs("qryDistribTransCount")
   currentdb.querydefs("qryLoansTransCount")
   currentdb.querydefs("qryContribElapsedAvg")
   currentdb.querydefs("qryDistribElapsedAvg")
   currentdb.querydefs("qryLoansElapsedAvg")
   DoCmd.OpenReport "rptERScorecard", acViewPreview

Exit_cmdRunContribTransCountQry_Click:
   Exit Sub

Err_cmdRunContribTransCountQry_Click:
   MsgBox Err.Description
   Resume Exit_cmdRunContribTransCountQry_Click
   
End Sub


to tell you the truth... i don't know exactly what these queries are doing. so i may be way off base.

dovholuk
0
 
LVL 2

Expert Comment

by:Yoink
ID: 7054723
As another option, you could covert each of your queries to SQL.

Private Sub cmdRunContribTransCountQry_Click()
On Error GoTo Err_cmdRunContribTransCountQry_Click

dim db as database
dim strSQL as string

set db = currentdb
strSQL="SQL version of qryContribTransCount"
db.execute strSQL
set db = currentdb
strSQL="SQL version of qryDistribTransCount"
db.execute strSQL
etc...
DoCmd.OpenReport "rptERScorecard", acViewPreview

Exit_cmdRunContribTransCountQry_Click:
   Exit Sub

Err_cmdRunContribTransCountQry_Click:
   MsgBox Err.Description
   Resume Exit_cmdRunContribTransCountQry_Click
   
End Sub

This solution too may be off base because I do not know exactly what your queries do.
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Introduction When developing Access applications, often we need to know whether an object exists.  This article presents a quick and reliable routine to determine if an object exists without that object being opened. If you wanted to inspect/ite…
Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Familiarize people with the process of utilizing SQL Server views from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Access…

708 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

17 Experts available now in Live!

Get 1:1 Help Now