CMD buuton to run selected query

Dgavilanes

Registered User.
Local time
Today, 22:57
Joined
Jun 25, 2001
Messages
109
CMD button to run selected query

Hi All,

When I use the following code in the cmd button I get a compile error

Sub Or Function not defined

Private Sub cmbQueries_Click()

Dim stDocName As String

If IsNull(Me!cmbQueries) Then
Call Message("Please select a query to edit.")
Else
stDocName = Me!cmbQueries
DoCmd.OpenQuery stDocName, AcFormView.acDesign, AcOpenDataMode.acEdit

End If

End Sub


Any assistance would be greatly appreciated

Dennis
 
Last edited:
This is incorrect:

AcFormView.acDesign, AcOpenDataMode.acEdit
 
It would be:

DoCmd.OpenQuery stDocName, acViewNormal, acEdit

But why open queries? I don't let users open queries or tables directly. I use a FORM for viewing queries or table information. You have more control over what they can do that way.
 
Thanks fo the quick reply, I replaced the code as suggested by the error message stil the same

Regards, Dennis
 
So, what does the code look like that you currently have (now with the changes) and which line does it highlight?
 
The call Message is highlighted

Private Sub cmbQueries_Click()
Dim stDocName As String

If IsNull(Me!cmbQueries) Then
Call Message("Please select a query to edit.")
Else
stDocName = Me!cmbQueries
DoCmd.OpenQuery stDocName, acViewNormal, acEdit

End If
End Sub
 
Ah, yes I should have spotted it sooner.

Call MsgBox("Please select a query to edit.")

or just use

MsgBox "Please select a query to edit."
 
Oh, and why are they opening a query to change the DESIGN of it?
 

Users who are viewing this thread

Back
Top Bottom