Forum Home
Press F1
 
Thread ID: 104416 2009-10-27 00:40:00 Replace space with underscore in Access fieldnames Mike (15) Press F1
Post ID Timestamp Content User
824461 2009-10-27 00:40:00 Hi all,

I have an access database with about 13 tables, each with about 15-20 fields. Most of the fieldnames contain spaces in them (such as "General Info"), and I need to change these field names so that there is no space, so want to replace the spaces with underscore ("General_Info").

Does anybody know how I can do this without having to change every space manually? (some fieldnames have multiple spaces)...

Thanks,
Mike.
Mike (15)
824462 2009-10-27 01:43:00 Can I ask you why you want to replace spaces with underscores? Software Developer (15363)
824463 2009-10-27 02:40:00 I don't want to... :)

I am joining the tables to tables in another application, and the other application doesn't like spaces in fieldnames. They don't need to be underscores, could just remove the spaces altogether... underscores just make it easier to read them.

Cheers,
Mike.
Mike (15)
824464 2009-10-29 04:21:00 Oops duplicate entry - I am on dial-up at the moment, pages don't refresh well. Software Developer (15363)
824465 2009-10-29 04:22:00 Oops duplicate entry - I am on dial-up at the moment, pages don't refresh well. Software Developer (15363)
824466 2009-10-29 04:23:00 Try put [] around the table names, e.g. use [General Info] instead of General Info when using them in other applications, SELECT * FROM [General Info]. Software Developer (15363)
824467 2009-10-29 08:10:00 Try put [] around the table names, e.g. use [General Info] instead of General Info when using them in other applications, SELECT * FROM [General Info].??

I need to replace spaces in field names, not select fields.

I'm guessing there isn't a quick and easy way to do it in Access... Or maybe I should import them all into excel, replace the spaces, then export them back :D

Mike.
Mike (15)
824468 2009-10-29 08:50:00 All I was saying, is if it was the spaces breaking your queries (as you said you wanted to join tables etc from another application), you could put [] around the table and field names that contain spaces and it would then work in your other application, e.g. "select * from general info" won't work but "select * from [general info] will. Software Developer (15363)
824469 2009-10-29 10:02:00 :)

The tables join alright, they just don't display, that's why I need to remove the spaces. It's an issue with the application.

Mike.
Mike (15)
824470 2009-10-29 18:06:00 Hmm, an interesting challenge.

Of greater immediate concern however is the impact that renaming tables and fields will have on the functions within this existing database. You may find you end up having to modify every query, form, macro and module as well in order to keep it working!

I'm tempted to suggest you do your modifications to a separate database which links to the tables in this database (ie a third database sited midway between the source and destination database applications, or alternatively, look to ways to export your data to a different database format (which might recognise and correct the issue automatically if you're lucky.

It all depends on how 'live' the database is - how much use it's getting and how up to date your data in the target app needs to be - whetther or not you'll be needed to repeat this process regularly to refresh the data.

A bit more info would be nice. Care to name the destination app or database structure?
Paul.Cov (425)
1 2