Solved

Hiding queries when opened from dialog box

Posted on 2002-06-04
3
176 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

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

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

When you are entering numbers in a speadsheet, and don't remember what 6×7 is, you just type “=6*7" instead. It works in every cell! This is not so in Access. To enter the elusive 42 in a text box, you have to find a calculator, and then copy the re…
A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
Familiarize people with the process of utilizing SQL Server stored procedures 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 Micr…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

911 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