Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Importing / Linking / August 2005

Tip: Looking for answers? Try searching our database.

Data type conversion from Excel

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Jon - 17 Aug 2005 01:48 GMT
I am trying to import an Excel spreadsheet. The fields in the
spreadsheet include a 6-digit code, some with leading zeros. These
cells are formatted as text. In the Access import wizard, the data type
in the field options is grayed out and it is importing the field as a
double. Is there any way to control the format on the import?

Jon Cosby
tina - 17 Aug 2005 01:56 GMT
you could save the Excel file as a .txt file, then import the .txt file.
using the Access import wizard, you have almost complete control of how data
imports from a text file.

hth

> I am trying to import an Excel spreadsheet. The fields in the
> spreadsheet include a 6-digit code, some with leading zeros. These
[quoted text clipped - 3 lines]
>
> Jon Cosby
Jon - 17 Aug 2005 20:53 GMT
Thanks Tina, that worked.

Jon

Tina wrote:
> you could save the Excel file as a .txt file,
> then import the .txt file. using the Access
> import wizard, you have almost complete control
> of how data imports from a text file.
tina - 17 Aug 2005 21:14 GMT
you're welcome  :)
it doesn't really solve the problem, like John's solution does; it just
sidesteps it. but it's what i usually do - i despise importing from Excel!
<g>

> Thanks Tina, that worked.
>
[quoted text clipped - 5 lines]
> > import wizard, you have almost complete control
> > of how data imports from a text file.
John Nurick - 17 Aug 2005 07:25 GMT
>I am trying to import an Excel spreadsheet. The fields in the
>spreadsheet include a 6-digit code, some with leading zeros. These
>cells are formatted as text. In the Access import wizard, the data type
>in the field options is grayed out and it is importing the field as a
>double. Is there any way to control the format on the import?

If you prefix the values in the Excel cells with an apostrophe ', it
forces them to be treated as text. These Excel VBA functions may help:

Sub AddApostrophesNumericToSelection()
 'adds apostrophes to numeric values only
 Dim C As Excel.Range
 For Each C In
Application.Selection.SpecialCells(xlCellTypeConstants).Cells
   If IsNumeric(C.Formula) Then
     C.Formula = "'" & C.Formula
   End If
 Next
End Sub

Sub AddApostrophesAllToSelection()
 Dim C As Excel.Range
 With ActiveWorkbook.ActiveSheet
   For Each C In Intersect(Selection,
.UsedRange).SpecialCells(xlCellTypeConstants).Cells
     C.Formula = "'" & C.Formula
   Next
 End With
End Sub

Sub AddApostrophesAllToColumn( _
     ByVal TheColumn As Long _
 )
 Dim C As Excel.Range
 With ActiveWorkbook.ActiveSheet
   For Each C In Intersect(.Columns(TheColumn), _
       .UsedRange).SpecialCells(xlCellTypeConstants).Cells
     C.Formula = "'" & C.Formula
   Next
 End With
End Sub

Sub RemoveApostrophes()
 Dim C As Excel.Range
 For Each C In Application.Selection.Cells
   C.Formula = C.Formula
 Next
End Sub

--
John Nurick [Microsoft Access MVP]

Please respond in the newgroup and not by email.
Michael J. Strickland - 17 Aug 2005 15:03 GMT
Have you tried clicking on the "Advanced" button just before the
wizard finishes and setting the data type to text there?

Signature

---------------------------------------------------------------
Michael J. Strickland
Quality Services                             qualityser@att.net
703-560-7380
---------------------------------------------------------------

>I am trying to import an Excel spreadsheet. The fields in the
> spreadsheet include a 6-digit code, some with leading zeros. These
[quoted text clipped - 3 lines]
>
> Jon Cosby
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.