Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
Access Discussion of Microsoft Access database design and programming. See also the forums for Access ASP and Access VBA.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old October 3rd, 2007, 06:35 AM
Friend of Wrox
 
Join Date: Oct 2006
Location: Northampton, Northants, United Kingdom.
Posts: 114
Thanks: 0
Thanked 0 Times in 0 Posts
Default SELECT from SELECT query?

I have a lot of queries which are along the lines of

SELECT * FROM CUSTOMER WHERE ...

We've added a limitation to the CUSTOMER table (and renamed it to CUSTOMER_MASTER) and now need to do a SELECT from a SELECT. We had done a search/replace in our central query module so that the above becomes:

SELECT * FROM (SELECT * FROM CUSTOMER_MASTER WHERE <limitation>) AS CUSTOMER WHERE ...

This would (I am pretty sure) work with SQL, but Access complains of an error in the FROM. Re-writing all the queries isn't an option because there's a serious quantity of them, which is why we opted for a search/replace in the query module (a set of functions that are passed a query and return the recordset).

Hope this explains things and any help would be appreciated.

Regards,

Sean Anderson
__________________
Regards,

Sean Anderson
  #2 (permalink)  
Old October 12th, 2007, 12:40 AM
Friend of Wrox
 
Join Date: Jul 2005
Location: Oklahoma City, OK, USA.
Posts: 150
Thanks: 0
Thanked 0 Times in 0 Posts
Default

When you change table names, there really is not shortcut to properly updating the queries. IMHO, All the queries should be fixed not patched. Your solution seams to be a harder way and will probably slower executing.

You may want to consider the product Speed Ferret.

You may also find this useful:

Public Sub UpdateFieldNameInQueries()

Dim qdf As DAO.QueryDef 'Note: you may need to set a reference to DAO

Const cFrom = "BRANCH ID"
Const cTo = "BRANCH_ID"

With CurrentDb

For Each qdf In .QueryDefs

qdf.SQL = Replace(qdf.SQL, cFrom, cTo,,,vbTextCompare)

Next qdf

End With

End Sub
from:
http://www.utteraccess.com/forums/sh...ost1513505&Zp=



Boyd
"Hi Tech Coach"
Access Based Accounting/Business Solutions developer.
http://www.officeprogramming.com


Similar Threads
Thread Thread Starter Forum Replies Last Post
Select Query gregalb SQL Server 2000 2 November 15th, 2007 10:56 PM
Need help on select query arul1984 SQL Server 2000 2 July 4th, 2007 01:49 AM
Select Query Help dbartelt Access 1 June 13th, 2005 08:06 AM
Select query help minhtri SQL Server 2000 4 March 28th, 2005 06:59 PM
select query collie SQL Server 2000 2 January 17th, 2005 03:13 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.