Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access VBA
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Access VBA Discuss using VBA for Access programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access VBA section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old September 8th, 2004, 09:37 AM
Registered User
 
Join Date: Sep 2004
Location: , , .
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default changing data type when importing Excel worksheet

Hello all! I am importing a worksheet from Excel and one of the fields Imports as a number. Since I do not perform any arithmetic on this field, I want it to be a text field (also in case they begin to add letters to this field). Is there anyway I can change the field type during the import procedure or do I have to do it afterwards? Here is my code for the import.

Public Function ImportFileVersion() As Boolean

Dim strPath As String
Dim strSQl As String

'Set the path
strPath = "S:\MIS\admin\MidAtl_Hierarchy_2004.xls"
strSQl = "DELETE * FROM tblHierarchy"

'If table exist, delete and update with latest version
'If table does not exist, continue
On Error Resume Next
    DoCmd.SetWarnings False
    DoCmd.RunSQL strSQl
    DoCmd.SetWarnings True

'Import the data only in this range from Excel
DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel9, _
    "tblHierarchy", strPath, True, "A1:H423"

'Open the table
DoCmd.OpenTable "tblHierarchy", acViewNormal

ImportFileVersion = True


End Function

Also if you see how my code can be more efficient, please feel free to chop it up.

Thanks in advance!

Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Importing Excel Data into a new Dataset Juan Patrick Visual Basic 2005 Basics 2 July 4th, 2007 09:03 PM
Changing Data type samnachilomo SQL Server 2000 1 November 25th, 2006 03:25 PM
Changing Data Type Behaviour mat41 SQL Server ASP 8 August 28th, 2006 07:17 PM
Changing data type error kuku SQL Server 2000 1 August 18th, 2005 10:20 AM
Changing data type JLN Pro VB 6 1 July 13th, 2004 12:49 PM



All times are GMT -4. The time now is 05:50 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.