Solved

Hiding queries when opened from dialog box

Posted on 2002-06-04
3
182 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

Question has a verified solution.

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

Phishing attempts can come in all forms, shapes and sizes. No matter how familiar you think you are with them, always remember to take extra precaution when opening an email with attachments or links.
In earlier versions of Windows (XP and before), you could drag a database to the taskbar, where it would appear as a taskbar icon to open that database.  This article shows how to recreate this functionality in Windows 7 through 10.
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 different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.

630 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