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

x
?
Solved

Hiding queries when opened from dialog box

Posted on 2002-06-04
3
Medium Priority
?
186 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 300 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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Access custom database properties are useful for storing miscellaneous bits of information in a format that persists through database closing and reopening.  This article shows how to create and use them.
Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
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…
Suggested Courses

885 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