Closing a Tab/Query

  • Thread starter Thread starter dhstein
  • Start date Start date
D

dhstein

I have a Query that runs via VB code executed from a Control. It doesn't run
twice in a row unless I close the Query. So I want to close the Query in VB
before I run it again. Any ideas are appreciated. Thanks.
 
I have a Query that runs via VB code executed from a Control. It doesn't run
twice in a row unless I close the Query. So I want to close the Query in VB
before I run it again. Any ideas are appreciated. Thanks.

Please post the code and the SQL of the query. Why do you need to run a query
multiple times??
 
Did you actually read John's reply???

Is so,

The code that runs the SQL is????????
The SQL View of the query is????????

With all due respect, how can someone hope to help you if they don't know
what your code is????

Regards

Mike B
 
MikeJohnB said:
Did you actually read John's reply???

Is so,

The code that runs the SQL is????????
The SQL View of the query is????????

With all due respect, how can someone hope to help you if they don't know
what your code is????

Regards

Mike B
--
Advice to Posters.
Check your post for replies or request for more information.
Consider providing some feed back to the response you have recieved.
Kindest Regards Mike B

With all due respect:

1) Thanks for taking the time to reply.
2) I did read John's request.
3) The code is extremely complicated - in multiple modules.
4) The code has nothing whatever to do with my question
5) It is just a VB question
6) You don't need to know my code to answer the question
7) In order to answer the question you have to know what the VB code is to
close an Open Query (one where the tab is showing)
8) So if you have a database and you run a query and the query is open, and
then you have a control that activates an event e.g. Private
Sub_btnMyButton_Click()
what vb code will close the open query?
9) It might be something like DoCmd.Something something - there is a
DoCmd.OpenQuery but none for close Query.
10) Thanks for your time - I'm not trying to P.O. anybody, just trying to
figure this out.
 
Try looking at

DoCmd.Close acQuery, queryname

I have not used this command except for closing forms. But acQuery is a
valid option but I am not sure of the queryname bit?

Let me know if I am barking up the right tree please?

Kindest Regards

Mike B
 
With all due respect:

1) Thanks for taking the time to reply. 2) I did read John's request.
3) The code is extremely complicated - in multiple modules. 4) The
code has nothing whatever to do with my question 5) It is just a VB
question
6) You don't need to know my code to answer the question 7) In order
to answer the question you have to know what the VB code is to close an
Open Query (one where the tab is showing) 8) So if you have a database
and you run a query and the query is open, and then you have a control
that activates an event e.g. Private Sub_btnMyButton_Click()
what vb code will close the open query? 9) It might be something like
DoCmd.Something something - there is a DoCmd.OpenQuery but none for
close Query. 10) Thanks for your time - I'm not trying to P.O. anybody,
just trying to figure this out.

There is not a CloseReport nor is there a CloseForm either. DoCmd.Close
is used for all of them.

DoCmd.Close acQuery, "QueryName"
 
MikeJohnB said:
Try looking at

DoCmd.Close acQuery, queryname

I have not used this command except for closing forms. But acQuery is a
valid option but I am not sure of the queryname bit?

Let me know if I am barking up the right tree please?

Kindest Regards

Mike B
--
Advice to Posters.
Check your post for replies or request for more information.
Consider providing some feed back to the response you have recieved.
Kindest Regards Mike B
Mike, You're definitely helping me. I'm having trouble figuring out the
syntax I need, but this looks like the right place. My Object is
qryByLongSKU but so far Idon't have the right syntax. I tried DoCmd.Close
acQuery, qryByLongSKU
and got:
Run-time error '2493"
This action requires an Object Name argument

I'll keep working on it. Please let me know if you figure it out. Thanks.

The Close method carries out the Close action in Visual Basic.
Syntax

expression.Close(ObjectType, ObjectName, Save)

expression A variable that represents a DoCmd object.

Parameters

Name Required/Optional Data Type Description
ObjectType Optional AcObjectType A AcObjectType constant that represents the
type of object to close.
ObjectName Optional Variant A string expression (string expression: An
expression that evaluates to a sequence of contiguous characters. Elements of
the expression can be: functions that return a string or a string Variant
(VarType 8); a string literal, constant, variable, or Variant.) that's the
valid name of an object of the type selected by the objecttype argument.
Save Optional AcCloseSave A AcCloseSave constant tha specifies whether or
not to save changes to the object. The default value is acSavePrompt
 
Open and close the query name in quotes
"qryByLongSKU" as the argument must be a string

DoCmd.Close acQuery, "qryByLongSKU"

I have proved this command on my trial database

Regards Mike B

--
Advice to Posters.
Check your post for replies or request for more information.
Consider providing some feed back to the response you have recieved.
Kindest Regards Mike B
 
Rick Brandt said:
There is not a CloseReport nor is there a CloseForm either. DoCmd.Close
is used for all of them.

DoCmd.Close acQuery, "QueryName"


--
Rick Brandt, Microsoft Access MVP
Email (as appropriate) to...
RBrandt at Hunter dot com
Mike and Rick,

Thanks so much - Mike had it and I just needed Rick to give me the Quotes -
so that worked. You can both have the rest of the day off. Thanks.
 

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

Back
Top