Close Query sub

RaunLGoode

Registered User.
Local time
Today, 07:08
Joined
Feb 18, 2004
Messages
122
I want to run a query to update a combo box prior to loading a form.
I am using the following code in the on click command to do this:

Private Sub cmdRunQuery_Click()
DoCmd.OpenQuery "qryActive", acViewNormal, acEdit
End Sub
I have examples for opening and closing forms, and opening the query, but I am missing something in the syntax. I am using Access 2000

I have tried to do this in the OnOpen event without success too, if anyone out there is feeling extra generous
 
More Info

I have tried the query as a select query and as a make table query. The problem isn't making the query run. I just want to close it once it has run.
There is a "Close Form" command and a "Close" command, but no "CloseQuery" Command.

When I tried to accomplish this with an"On Open" event, I didnt get as far.

Private Sub Form_Open(Cancel As Integer)
DoCmd.OpenQuery , "qryActive", acViewNormal, acEdit
End Sub
And got the message:
Compile Error, Argument Not Optional
I'm pretty sure this is syntax related, But this rookie is lost.
 
Wht not do it this way...

Private Sub Form_Open(Cancel As Integer)
Me.ComboboxName.Requery
End Sub
 
RaunLGoode said:
Private Sub Form_Open(Cancel As Integer)
DoCmd.OpenQuery , "qryActive", acViewNormal, acEdit
End Sub
And got the message:
Compile Error, Argument Not Optional
I'm pretty sure this is syntax related, But this rookie is lost.

As an aside, as I'm with Pat on this, the reason for you error is because you have missed out an argument. Such arguments in this instance are the constants and strings you 'pass' to make the query open: "qryActive", acViewNormal, acEdit

In you code, you have a comma before the name of the query. The name of the query should go before this comma. The fact that you are trying to pass this off with what the computer thinks is no query name it is stalling because the argument passed is compulsory and not optional.
 

Users who are viewing this thread

Back
Top Bottom