DoCmd.OpenQuery ???

ccflyer

Registered User.
Local time
Today, 16:00
Joined
Aug 12, 2005
Messages
90
I'm somewhat new to VB so please hang with me. I am trying to run a query using VB when I click a command button, then close the query so the user doesn't see it happening but it doesn't seem to be working. This is what I have for code so far:

(My Query is named "DateWellPrevious")
Code:
Private Sub test_Click()
DoCmd.SetWarnings False
DoCmd.OpenQuery(DateWellPrevious,acViewNormal,[acEdit])
DoCmd.Close(acQuery,[DateWellPrevious],[acSaveYes])
End Sub
It says that it expects an equals sign after the DoCmd.OpenQuery statement and the DoCmd.Close statement.

Any Suggestions?
-Chris
 
ccflyer said:
I'm somewhat new to VB so please hang with me. I am trying to run a query using VB when I click a command button, then close the query so the user doesn't see it happening but it doesn't seem to be working. This is what I have for code so far:

(My Query is named "DateWellPrevious")
Code:
Private Sub test_Click()
DoCmd.SetWarnings False
DoCmd.OpenQuery(DateWellPrevious,acViewNormal,[acEdit])
DoCmd.Close(acQuery,[DateWellPrevious],[acSaveYes])
End Sub
It says that it expects an equals sign after the DoCmd.OpenQuery statement and the DoCmd.Close statement.

Any Suggestions?
-Chris
I would think it's just

DoCmd.OpenQuery "DateWellPrevious"

you don't have to add the options.
 
more to the point, why are you trying to open an close the query anyway? what are you trying to achieve?

Peter
 
I am trying to run a query without the user seeing anything, but actually the more I think of I, you are right, I don't need a Close command - Thanks.

But I did try
DoCmd.OpenQuery "DateWellPrevious"
and it didn't work.

EDIT: I did get it, I ended up using this
DoCmd.OpenQuery "QueryNameHerre", acViewNormal, acEdit

-Chris
 
Last edited:
It expects an equal sign because when you use brackets you are calling a function.

x = DoCmd.OpenQuery("DateWellPrevious")

Use this (and without the optional parameters too):

DoCmd.OpenQuery "DateWellPrevious"

ccflyer said:
I'm somewhat new to VB so please hang with me. I am trying to run a query using VB when I click a command button, then close the query so the user doesn't see it happening but it doesn't seem to be working. This is what I have for code so far:

(My Query is named "DateWellPrevious")
Code:
Private Sub test_Click()
DoCmd.SetWarnings False
DoCmd.OpenQuery(DateWellPrevious,acViewNormal,[acEdit])
DoCmd.Close(acQuery,[DateWellPrevious],[acSaveYes])
End Sub
It says that it expects an equals sign after the DoCmd.OpenQuery statement and the DoCmd.Close statement.

Any Suggestions?
-Chris
 
Hey thanks, that did work without the parentheses.

-Chris
 

Users who are viewing this thread

Back
Top Bottom