Import excel format (1 Viewer)

pekajo

Registered User.
Local time
Today, 11:35
Joined
Jul 25, 2011
Messages
133
Hi,
I have an issue with the DoCmd.TransferSpreadsheet acImport command.
One of the import fields is a phone number which has all kinds of numbers such as 03 87698076, N/A, as well as mobile 6756434546 (majority). It appears it read the data as numeric and drops all data that is not numeric or has spaces.
Is there a way of importing and making this field Text so it does not drop this data.
I have tried formatting the excel but it does not work.
Thanks
Peter
 

theDBguy

I’m here to help
Staff member
Local time
Yesterday, 18:35
Joined
Oct 29, 2018
Messages
21,467
Hi. Since you want the data as Text anyway, can you add some dummy text data on the first row/record?
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 09:35
Joined
May 7, 2009
Messages
19,230
edit the Excel file and specifically change the Format of the Column to Text.
 

pbaldy

Wino Moderator
Staff member
Local time
Yesterday, 18:35
Joined
Aug 30, 2003
Messages
36,125
I suspect you could also create an import spec that specified the data types.
 

Galaxiom

Super Moderator
Staff member
Local time
Today, 11:35
Joined
Jan 20, 2009
Messages
12,851
Unless the columns have a specific datatype defined the import looks at the values in the first few row and decides the datatype based on them.

Alternatively put a row with values that are definitely text at the top.

I don't think import specs are supported for Excel files.
 

pbaldy

Wino Moderator
Staff member
Local time
Yesterday, 18:35
Joined
Aug 30, 2003
Messages
36,125
I don't think import specs are supported for Excel files.

I think you're right. I know I use them for csv files, which are text files even though they'll open in Excel.
 

Pat Hartman

Super Moderator
Staff member
Local time
Yesterday, 21:35
Joined
Feb 19, 2002
Messages
43,257
Since Import Specs are not allowed for Excel files, you have two choices and both require some Excel automation.
1. Open the Excel file and save as .csv. That will allow you to use an Import SPEC.
2. Open the Excel file and change the column format as arne suggested or insert a dummy row as row 2 with dummy data in the format you want to be assumed. This is less effective than arne's suggestion since as Galaxiom mentioned, Access and Excel are in cahoots and Access examines ~ 20-30 records and uses them to determine the data type. If all are numeric, the assumption will be numeric. If all are dates, the assumption will be a date. If there is a mix or all are text, the assumption will be text.
 

CJ_London

Super Moderator
Staff member
Local time
Today, 02:35
Joined
Feb 19, 2013
Messages
16,605
there is another way to force text. Whether it is of use to you depends on what you are doing with the data.

Ensure the range includes the header row but set the hasheading property to no. Columns will import with headings F1, F2 etc and the first row will contain the header information which you will need to ignore. All fields will consequently be text. But this is easily handled if you are using a query to then update your table/s
 

pekajo

Registered User.
Local time
Today, 11:35
Joined
Jul 25, 2011
Messages
133
Thanks all for your help.
I have fixed it at the source.
 

Users who are viewing this thread

Top Bottom