Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Modules / DAO / VBA / February 2006

Tip: Looking for answers? Try searching our database.

Open Query from command form parameters

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
dmericksen - 06 Feb 2006 21:36 GMT
Hello-

I am having a problem with DoCmd.OpenQuery syntax.  Can you help me with
proper syntax.  I want to open a query that is specified in a form list box
(users select the query they want and click submit).

[Report Generator] = Form name
[reportFileName] = name of query

Here is the code I have been working with:

Private Sub Command60_Click()
DoCmd.OpenQuery [Forms]![Report Generator]![reportFileName]
End Sub

Also, do you know how I can add in some logic so if the file name selected
in the list box is a query than open the query, otherwise open a report. I
was thinking something like this.

if field x = x
then OpenQuery [Forms]![Report Generator]![reportFileName]
else OpenReport [Forms]![Report Generator]![reportFileName]
 
Ofer - 06 Feb 2006 21:53 GMT
Just to make sure

Is [reportFileName] the name of the list box on the form? (it should be)
===============================================
You can use
DoCmd.OpenQuery Me.reportFileName
===============================================
Does the list box has only one column?
If the query name is the second column in the list box, then use

DoCmd.OpenQuery Me.reportFileName.Column(1)

The column count start with 0
===============================================

Do you get any error? and what ?
Signature

\\// Live Long and Prosper \\//
BS"D

> Hello-
>
[quoted text clipped - 19 lines]
> else OpenReport [Forms]![Report Generator]![reportFileName]
>  
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.