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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Modify query using VBA

Status
Not open for further replies.

jane30

Programmer
Nov 14, 2000
92
0
0
US
Hi, There are more than 10 queries in my Access97 database. All of them are based on the same master table. I want to change the table name. It's kind of tedious to change all the queries on by on. Can I use VBA code to do so? Many thanks in advance.[3eyes]
 
Jane,

Yes, look into the queryDefs collection, and the queryDef object. A queryDef has a SQL property, which can be changed via code.

On the other hand, things like this come up often. Most developers I know own either speedFerret or Find n Replace (by Rick Fischer). I have the latter. I've used the former. They're both great. They both do global find and replace stuff.

If you really have no money, you'll have to deal with code. But if the money is available, it will save you HOURS AND HOURS OF WORK, and there is no question that you or your boss will recover the cost in the first few months of owning either one.

Jeremy =============
Jeremy Wallace
Designing, Developing, and Deploying Access Databases Since 1995

Take a look at the Developer's section of the site for some helpful fundamentals.


Remember to reward helpful tips with the stars they deserve.
 
Jeremy, thanks for the info. I'll talke to the boss about the utilities you recommended. By the way, I do have a question that're might be easy for you, a question about Access Pivot table: Can the recordsource of a Pivot table be changed? Here is the scenario: I have over 10 queries. I created Pivot1 for query1. Then copied Pivot1 and named as Pivot2. I went to the Pivot2's recordsource and chose query2 as its recordsource. Then I ran the Pivot2 and refreshed the data. The result still contained query1 data.(FYI, All the queries have very similar record layout). Why is that? How does Access recognize the table/query that Pivot table is created on? Or is it a bug in Access97? I've posted this question every Access forum that I can find on the web. Some people said Ms. Access can't change the recordsource. Some said just changed the recordsource. I did, it didn't work. Another question about Pivot table: I add a new field to the table/query. How can I make it part of the Pivot table created on that table/query? Please help. Thanks a bunch.[ponder]
 
Jane,

Never used a pivot table. Start a new thread, so people can see what you're asking about and you're sure to get some help.

Jeremy =============
Jeremy Wallace
Designing, Developing, and Deploying Access Databases Since 1995

Take a look at the Developer's section of the site for some helpful fundamentals.


Remember to reward helpful tips with the stars they deserve.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top