Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access VBA
|
Access VBA Discuss using VBA for Access programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access VBA 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
 
Old April 21st, 2008, 12:38 PM
Registered User
 
Join Date: Apr 2008
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

In a similar fix, I'm wondering if I can just use a make-table query to produce the new version, aliasing the old field names in the query with the new ones (NewName:[OldName]), swap table names around and then delete the original table. The hard part is fixing up all the references in my forms, queries & reports, but I'm testing Chas Dillon's utility from

http://allenbrowne.com/ser-41.html

for the purpose (requires some VBA facility). I gather that there are good reasons why it's not practical for you to rename Excel columns before import.
 
Old August 10th, 2009, 04:42 PM
Registered User
 
Join Date: Aug 2009
Posts: 2
Thanks: 1
Thanked 0 Times in 0 Posts
Default

Thanks, Alan -- this was exactly what I was looking for and your code worked perfectly.
 
Old August 13th, 2009, 08:39 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,151
Thanks: 2
Thanked 14 Times in 14 Posts
Send a message via ICQ to SerranoG Send a message via AIM to SerranoG
Default

Quote:
Originally Posted by elansolutionsltd View Post
Despite the cynical comments you have so far received, I too have to do this regularly.
Yes, Alan, there are some people here that question what someone wants to do in the interest of supplying a "better" answer or deterring "bad habits," and they sound condescending doing it. They may not realize it but the advice is often times good. Sometimes avoiding a method prevents headaches down the line.

In this case, the sentiment is that it's too much of a hassle and highly irregular to change field names using code. In my case, I would just write a make-table query where the input is the linked table in question and the output is my version of the table with the new field names using the calculated method MMcDonal suggested. Then I would work with my version of the table.

As for the condescending tones, I sometimes reply with my own tone or outrightly say, "Could you please dispense your advice without the judgement? It's not necessary." Oh... and then I thank them for the solution... of course!
__________________
Greg Serrano
Michigan Dept. of Environmental Quality
Air Quality Division
 
Old August 13th, 2009, 02:22 PM
Registered User
 
Join Date: Aug 2009
Posts: 2
Thanks: 1
Thanked 0 Times in 0 Posts
Thumbs up Second guessing questions

Quote:
Originally Posted by elansolutionsltd
Despite the cynical comments you have so far received, I too have to do this regularly
I can't speak to the person who originally started this thread -- but in my case I had a very good reason to need to rename fields in VBA. I had a list of 163 field names in one column in one file and then a 163 field pipe-delimited data file without a header record in another file. Yes, there are a number of ways I could have achieved success without VBA (and without VBA in access to change field names); but Alan's solution was certainly the least painful -- and even though he posted the solution nearly 5 years ago (!) seemed custom built to my particular problem.

Although I can appreciate those with more experience trying to pass on "best practices" -- My approach in those situations is to just answer the question posed. Then -- turn it around and see if the person was actually asking the "right" question.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Renaming long file name with VBA JillB Excel VBA 1 March 24th, 2008 06:20 PM
How to add fields to an existing table using VBA donrafeal Access VBA 3 March 22nd, 2006 06:11 PM
How to replace pivot table data fields using VBA? rstober Excel VBA 2 August 19th, 2005 06:06 AM
Renaming a table ... ERROR ?! SKE Classic ASP Databases 2 May 16th, 2005 06:04 AM
Renaming a Column/Field in Access Table james_sellwood ASP.NET 1.0 and 1.1 Professional 3 February 4th, 2005 08:45 AM





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