Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default Need to keep text format when retrieving records from database

I'm importing records from an access database to excel using ADO. When the
records are stored in the excel sheet, the format has changed. How do I keep
it to a text format. For example, record 9900000000000080 has changed from
text to general and now looks like 9.9E+15.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 252
Default Need to keep text format when retrieving records from database

When I use ADO to extract from Access to xl I use the following code to
format several columns:

The variable "ExtractFields" is the xl Named Range of Field Names ( at the
top of each col of the extract range)

Dim Field As ADODB.Field
Dim k as interger

k = 1
For Each Field In rs.Fields
If Field.Type = adDate Then
ExtractFields(k).EntireColumn.NumberFormat = "mm/dd/yy"
ElseIf Field.Name Like "Age" Then
ExtractFields(k).EntireColumn.NumberFormat = "00"
ExtractFields(k).EntireColumn.HorizontalAlignment = xlCenter
End If
k = k + 1
Next Field

You should be able to adapt the above to your situation, changing to
whatever format you want for the desired field. Or just manually select the
column and select FormatCellsNumber to change the format after extracting.


"Markantesp" wrote:

I'm importing records from an access database to excel using ADO. When the
records are stored in the excel sheet, the format has changed. How do I keep
it to a text format. For example, record 9900000000000080 has changed from
text to general and now looks like 9.9E+15.

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Records Database Lane Excel Discussion (Misc queries) 2 November 21st 08 07:05 PM
Creating a Product DATABASE in ACCESS or EXCEL and then retrieving Abe Excel Discussion (Misc queries) 1 February 25th 06 03:09 AM
Retrieving data from database (MS Sql Server) to Excel nwhan Excel Discussion (Misc queries) 0 July 22nd 05 09:35 AM
Retrieving data from a database list RestlessAde Excel Discussion (Misc queries) 2 February 22nd 05 09:15 PM
Adding New Records To Excel Database.. Tom Ogilvy Excel Programming 1 August 18th 03 08:47 PM


All times are GMT +1. The time now is 07:24 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"