Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Add a column to An existing QUERY via code 1

Status
Not open for further replies.

Trob70

Programmer
Sep 25, 2012
89
AU
I have quite a large number of mdb databases that i need to adjust an existing query
The field is allready in the table used by the query
The field name is PubDetail the mdb is name Web1.mdb the table is Master1



I intend to load the databses into an array and loop through
the databases and adjust the query in each via code

Woukd appreciate some help with the code to do this...i seem to be
able to find code to alter a table but not a query ???



Regards Trob70
 
I have come up with a solution !!

Delete the existing query
Create a new query

I guess this is the best solution ?????

Regards Trob70
 
Is this an actual VB6 question? Sure smells like something for one of the many Access forums here.
 
Hi Trob70,

Checkout the QueryDef object.
You can change the underlying SQL statement of a query. Example:
Code:
Dim qdef As QueryDef
Set qdef = yourDb.QueryDefs(NameOfQueryToBeChanged)
qd.SQL = "SELECT ..., PubDetail FROM Master1"
qd.Save

Cheers,
MakeItSo

"Knowledge is power. Information is liberating. Education is the premise of progress, in every society, in every family." (Kofi Annan)
Oppose SOPA, PIPA, ACTA; measures to curb freedom of information under whatever name whatsoever.
 
MakitSo

Thanks for the tip

The code did the job..
Had to alter qd.Save to qd.close


Regards Trob70
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top