External Name Not Defined msg during debugging a module

J

Joanne

I am using Access 97. I placed command buttons on a
dialog box that shows a list of queries. I am able to
have the first entry highlighted but I am unable to
operate 2 of the command buttons. One is to preview the
highlighted query and the other is to display the query.

This is the procedure I wrote:
Private Function PreviewQuery()
'open the selected query inthe Print Preview window
DoCmd.OpenQuery [QueryList], acViewPreview
End Function

Private Function DisplayQuery()
'Open the selected query in DAtasheet view
DoCmd.OpenQuery [QueryList], acViewNormal
End Function

When debugging I get the External Name Not Defined and
[QueryList] Highlighted.

QueryList worked fine with the highlighting of the first
query so what is my problem?
 
C

Chris Nebinger

The OpenQuery method requires a string variable of the
query name.

DoCmd.OpenQuery "QueryList",acViewPreview


That assumes the name of the query is QueryList


Chris Nebinger
 
M

Marshall Barton

Joanne said:
I am using Access 97. I placed command buttons on a
dialog box that shows a list of queries. I am able to
have the first entry highlighted but I am unable to
operate 2 of the command buttons. One is to preview the
highlighted query and the other is to display the query.

This is the procedure I wrote:
Private Function PreviewQuery()
'open the selected query inthe Print Preview window
DoCmd.OpenQuery [QueryList], acViewPreview
End Function

Private Function DisplayQuery()
'Open the selected query in DAtasheet view
DoCmd.OpenQuery [QueryList], acViewNormal
End Function

When debugging I get the External Name Not Defined and
[QueryList] Highlighted.

QueryList worked fine with the highlighting of the first
query so what is my problem?


I don't know why any of that worked, you need to use a
string to specify the name of the query:

DoCmd.OpenQuery "QueryList", . . .
 
J

Joanne

THanks for the help
-----Original Message-----
Joanne said:
I am using Access 97. I placed command buttons on a
dialog box that shows a list of queries. I am able to
have the first entry highlighted but I am unable to
operate 2 of the command buttons. One is to preview the
highlighted query and the other is to display the query.

This is the procedure I wrote:
Private Function PreviewQuery()
'open the selected query inthe Print Preview window
DoCmd.OpenQuery [QueryList], acViewPreview
End Function

Private Function DisplayQuery()
'Open the selected query in DAtasheet view
DoCmd.OpenQuery [QueryList], acViewNormal
End Function

When debugging I get the External Name Not Defined and
[QueryList] Highlighted.

QueryList worked fine with the highlighting of the first
query so what is my problem?


I don't know why any of that worked, you need to use a
string to specify the name of the query:

DoCmd.OpenQuery "QueryList", . . .
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top