query run in subform and not in separate window

C

c8tz

hi,

i've created my form and have a query that runs within a subform.
This is working fine except that the same query runs in a separate
window also.
How do I prevent the separate window from opening but only run within
the subform.

thanks heaps
 
D

Douglas J. Steele

What do you mean by having "a query that runs within a subform"?

What are you doing to run it?

What kind of query is it? If it's a SELECT query, typically you'd set it as
the RecordSource for the form being used as the subform, and not run it. If
it's an Action query (INSERT INTO, DELETE, UPDATE, SELECT ... INTO), you
wouldn't typically have anything displayed on the form.
 
C

c8tz

What do you mean by having "a query that runs within a subform"?

What are you doing to run it?

What kind of query is it? If it's a SELECT query, typically you'd set it as
the RecordSource for the form being used as the subform, and not run it. If
it's an Action query (INSERT INTO, DELETE, UPDATE, SELECT ... INTO), you
wouldn't typically have anything displayed on the form.

--
Doug Steele, Microsoft Access MVPhttp://I.Am/DougSteele
(no e-mails, please!)








- Show quoted text -

DoCmd.SetWarnings False
DoCmd.OpenQuery "AppendTrialFerts"
DoCmd.OpenQuery "AppendBasalFerts"

DoCmd.OpenQuery "TrialFerts"
Me!TrialFertilizerReqs.Form.Requery
Me!TrialFertilizerReqs.Form.Refresh
TrialFertilizerReqs.Visible = True

This is the code that I put in for the command button to open the
query within the form. This works well but the query also opens up in
a separate window. I would like only for the query to open in the
subform but not in the separate query window.

thanks
 
D

Douglas J. Steele

If TrialFerts is the recordsource for the subform, there's no reason to use
OpenQuery on it. Simply remove that line of code.

Assuming that AppendTrialFerts and AppendBasalFerts are action queries
(Append, Delete, Update or Make Table), OpenQuery isn't a great way to run
them. Instead, use:

CurrentDb.QueryDefs("AppendTrialFerts").Execute dbFailOnError
CurrentDb.QueryDefs("AppendBasalFerts").Execute dbFailOnError

That has the advantage of not popping up the message saying "n records are
going to be append, do you want to continue?", plus will generate a
trappable error if something goes wrong running the query.
 
C

c8tz

If TrialFerts is the recordsource for the subform, there's no reason to use
OpenQuery on it. Simply remove that line of code.

Assuming that AppendTrialFerts and AppendBasalFerts are action queries
(Append, Delete, Update or Make Table), OpenQuery isn't a great way to run
them. Instead, use:

CurrentDb.QueryDefs("AppendTrialFerts").Execute dbFailOnError
CurrentDb.QueryDefs("AppendBasalFerts").Execute dbFailOnError

That has the advantage of not popping up the message saying "n records are
going to be append, do you want to continue?", plus will generate a
trappable error if something goes wrong running thequery.

--
Doug Steele, Microsoft Access MVPhttp://I.Am/DougSteele
(no e-mails, please!)










- Show quoted text -

thanks for your help...... i initially thought the openquery was
needed to actually run the query.. it works fine now.
with the append queries i used docmd.show warnings false and
then ..... warnings true at the end.

thanks heaps again.
 

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