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]
>