Query twice with the same criteria ==>

D

dede

I will run two "make-table" query with the same criteria
I call those two query from a form with
DoCmd.OpenQuery
the criteria in the query is twice "[Entrer No CRA]"
where and how could I save this constant (write in the msgbox) to call it
again in the next query ?

Thanks for any help.
 
V

vanderghast

Make the criteria in the form of FORMS!formNameHere!controlNameHere

as long as the said form is open (can be invisible, if you wish).

Fill the control with the wanted value, then run the two DoCmd commands.


Vanderghast, Access MVP
 
J

Jeff Boyce

Why are you making tables? You've described 'how' you are trying to solve
some problem, but not the underlying issue.

If you'll provide more specific description of the issue you're working on,
folks here may be able to offer more specific suggestions...

Regards

Jeff Boyce
Microsoft Access MVP

--
Disclaimer: This author may have received products and services mentioned
in this post. Mention and/or description of a product or service herein
does not constitute endorsement thereof.

Any code or pseudocode included in this post is offered "as is", with no
guarantee as to suitability.

You can thank the FTC of the USA for making this disclaimer
possible/necessary.
 
J

John W. Vinson

I will run two "make-table" query with the same criteria
I call those two query from a form with
DoCmd.OpenQuery
the criteria in the query is twice "[Entrer No CRA]"
where and how could I save this constant (write in the msgbox) to call it
again in the next query ?

Thanks for any help.

I'd suggest instead putting an unbound textbox on the Form, and use a
criterion referencing it. Instead of a criterion of [Entrer No CRA] use
something like

[Forms]![YourFormName]![YourTextboxName]


One concern: I'd be very very reluctant to use MakeTable queries in any
production database. They bloat the database, clutter it with new tables, and
they are very rarely actually needed; there's not much that you can do with a
Table that cannot also be done with a properly designed Select Query
referencing existing tables. What are these two new tables, and why do you
feel that you need them?
 
D

dede

I will first thank you for your help
Regarding your answer, I will be able to make oly one “MakeTable Queryâ€
But I will explain you why I need a MakeTable queries. I have two table

Table A
CRA N° object_Id application date
1 10
1 11
1 12
2 11
2 21
3 10
3 12
3 32

Table B
CRA N° test_item CRA Status
1 test 100 x
2 test 200 y
3 test 300 z

I will first retrieve all object_Id from one CRA N°  I create a table
containing those objects_Id
When I will make a report containing each objects & for each one all CRA N°
associate
Did you see a other way to do it ?

John W. Vinson said:
I will run two "make-table" query with the same criteria
I call those two query from a form with
DoCmd.OpenQuery
the criteria in the query is twice "[Entrer No CRA]"
where and how could I save this constant (write in the msgbox) to call it
again in the next query ?

Thanks for any help.

I'd suggest instead putting an unbound textbox on the Form, and use a
criterion referencing it. Instead of a criterion of [Entrer No CRA] use
something like

[Forms]![YourFormName]![YourTextboxName]


One concern: I'd be very very reluctant to use MakeTable queries in any
production database. They bloat the database, clutter it with new tables, and
they are very rarely actually needed; there's not much that you can do with a
Table that cannot also be done with a properly designed Select Query
referencing existing tables. What are these two new tables, and why do you
feel that you need them?
 
J

John W. Vinson

I will first thank you for your help
Regarding your answer, I will be able to make oly one “MakeTable Query”
But I will explain you why I need a MakeTable queries. I have two table

Table A
CRA N° object_Id application date
1 10
1 11
1 12
2 11
2 21
3 10
3 12
3 32

Table B
CRA N° test_item CRA Status
1 test 100 x
2 test 200 y
3 test 300 z

I will first retrieve all object_Id from one CRA N° ? I create a table
containing those objects_Id
When I will make a report containing each objects & for each one all CRA N°
associate
Did you see a other way to do it ?

Yes. Create an appropriate Query.

Your MakeTable query already contains all the information that you need, just
as a SELECT QUERY. You do not need to write all that data wastefully to a new
table in order to create a Report; just base the report directly on the query.

I'm not sure I understand your logic though.
 
D

dede

I do not really see how
I will have first to ask the user which CRA_N° to retrieve all object_Id
associated
When I will have retrieve for each object_Id all CRA_N° & test_item =

After the first question (example 3)
3 10
3 12
3 32

=====> Results
1 10 test 100
3 10 test 300
1 12 test 100
3 12 test 300
3 32 test 300
 

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