Solved

Hiding queries when opened from dialog box

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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

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

You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
The Windows Phone Theme Colours is a tight, powerful, and well balanced palette. This tiny Access application makes it a snap to select and pick a value. And it doubles as an intro to implementing WithEvents, one of Access' hidden gems.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …

734 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