ms-access


How to remove spaces from field names when importing external data into MS Access 2010


I have an external file that I don't create which I need to import on a rolling basis, most of the column headers/field names have spaces in them. Is there a query I can write to change all of them at once? I'd rather not write a long query to get rid of spaces for each individual field name. The field names are always the same and in the same order in the file, the spaces are in the middle of the field names (ex: "Employee Number").
First of all, "query" refers to an SQL statement (including those viewed in Design View) that retrieve or act on data already in the database. Importing data from an external file is a separate action, not generally called a query. So strictly speaking the answer is "no".
However, Access does have built-in import functionality in Access. I suppose you can call these import "functions" or "actions" or "processes", just not queries. And I'm not being a smart aleck, since much of getting help with applications and code is learning and using the correct terms.
Go to the External Data ribbon (a.k.a. toolbar) along the top of Access.
Click the Import Text File icon (careful not to click the Export Text File icon, since they look similar. Hover the mouse cursor over each button to see the text description of it).
Choose the filename, and pick which import option
As Gustav instructs in his answer, choosing "Link to data source by creating a linked table" is the most efficient solution for external files that don't change format. The linked table (hence the external file) can be re-queried without repeating numerous steps.
Walk through the Import Wizard steps. Play with the options if you need to figure it all out.
In particular, make sure to check "First Row Contains Field Names"
On one of the wizard steps, you can edit the field names to remove the spaces.
On the last step, click the "Save Import Steps" checkbox, specify a name, then click the "Save Import" button
To re-use the previously-saved import steps:
Go to the External Data ribbon (a.k.a. toolbar) along the top of Access.
Click "Saved Imports" button
Choose your saved import settings
Click Run
OR if you created a Linked table
There is no need to "re-import". Instead, a normal Access query can be used to get the data and update one of your normal data tables.
If the path of the external files changes, this can also be updated by right-clicking the linked table and choosing Linked Table Manager (also available on the External Data ribbon). Select the table in the list and also check "Always prompt for new location" before clicking OK. A standard file selection dialogue will be shown for selecting a new filepath.
(Just to be complete, it is also possible to write VBA code in Access to open a file, read and analyze the headers and then import the data according to your custom behavior, but this isn't for you if you'd "rather not write a long..." something to do this.)
I'd rather not write a long query to get rid of spaces for each individual field name.
Maybe not, but there is no smart way to overcome this.
However, don't import the file but link it. Then use the linked file as source in your query. In this, alias the field names as you prefer, and do basic filtering and conversion of data. Then use this query for your further processing.

Related Links

Access 2013 Expression Builder not displaying
Missing ACCDB database drivers
MS Access Form button that allows user to browse/choose file, then imports file to a table
Can codesmith generator work with MS Access provider?
Access file unable to run in x64
Form.Seltop not selecting top most record
I have an ADO recordset, now I want to create a table from it but not at its connection location. How?
weighted average caluculation in access table
inputting info from one text box to another with command button
Sending attachments using access vba
Removing certain strings in an Access 2010 query
MS Access - Hide Columns on Subform
How to fix in oracle sql developer server new connection acces tab missing?
Invalid Syntax using DLookUp
How can I make a form to open by pressing a key combination in Ms Access 2010?
MS Access parameter: enter multiple values or leave blank to return all records

Categories

HOME
winforms
amazon-ec2
zeromq
oracle11g
drivers
dictionary
nullpointerexception
plone
layout
relative-path
rsyslog
facebook-php-sdk
offline
postgres-xl
resize
size
static-libraries
quickfix
jsprit
workload-scheduler
worldwind
opentracing
footer
serilog
aurigma
sms-gateway
visual-composer
scichart
errorlevel
lcd
sparse-matrix
poltergeist
url-scheme
nhapi
rst2pdf
subdomains
objectanimator
unboundid
preg-match-all
phpfreechat
catalog
revolution-slider
xenforo
ncalc
heightmap
import-from-excel
sencha-touch-2.3
cubic-spline
dds
blogengine.net
datastax-startup
forever
sybase-asa
zendesk-app
bind9
orthogonal
specrun
file-writing
phishing
merge-conflict-resolution
disque
nsviewcontroller
actionbardrawertoggle
hexdump
system.management
pyke
javax.sound.midi
muse
internet-connection
onactivityresult
jquery-layout
doskey
bundles
srs
monomac
.aspxauth
runtime.exec
blending
bulkloader
padarn
drools-planner
factory-method
angularjs-controller
anonymous-methods
coderush
dice
frameset
viewswitcher
onsubmit
chrono
bubble-chart
gnu-prolog
genshi
hamachi
f#-powerpack
javax.script
winbugs14
yslow
bespin
brewmp
audio-capture
exchange-server-2003
backcolor
data-driven

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App