Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Tags Active Topics RSS Search Mark Forums Read

Reply
 
Thread Tools Search this Thread
  #1  
Old 17-04-2009
Member
 
Join Date: Jan 2009
Posts: 86
How to import Text into Access through VBA

Hi friends,

I have written a code in VBA ,where i am trying to import a text file into a table in Access 2000 using VBA.Everything is working fine but when i try to open ant string and get data at that time i am getting an error message as "Variable Not Defined".

Can anyone fix this issue for me.
Reply With Quote
  #2  
Old 17-04-2009
Member
 
Join Date: Dec 2008
Posts: 164
Re: How to import Text into Access through VBA

Sure i will help you out with this i would really appreciate if you can provide me the code where i can find out where you have made mistake.
Reply With Quote
  #3  
Old 17-04-2009
Member
 
Join Date: Jan 2009
Posts: 86
Re: How to import Text into Access through VBA

Here is the code

Code:
Function ImportTextFile()
Dim LineData As String
Dim timpAN As String ' Holder for Account Number in text file
Dim timpCT As String ' Holder for the Cusip Number or Ticker Symbol
Dim nimpSH As Double ' Holder for the number of shares held in account
Dim timpLS As String ' Holder for Long or Short Position
Dim nimpVAL As Double ' Holder for value of security
Dim nimpNAV As Double ' Holder for Net Asset Value

' Open the text file
Open "C:\Documents and Settings\User\Desktop\CS060104.txt" For Input As #1
' Open the table to insert the text file into
DoCmd.OpenTable "tblTextFile", acNormal, acEdit

Do While Not EOF(1)
' Read a line of data.
Line Input #1, LineData

timpAN = Left(LineData, 8)
tblTextFile.AcctNumber = timpAN

timpCT = Mid(LineData, 10, 9)
nimpSH = Mid(LineData, 20, 14)
timpLS = Mid(LineData, 35, 1)
nimpVAL = Mid(LineData, 37, 14)
nimpNAV = Mid(LineData, 52, 9)
Loop

' Close the data file.
Close #1
and it gets stops a on the line of code "tblTextFile.AcctNumber = timpAN"
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: , , ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "How to import Text into Access through VBA"
Thread Thread Starter Forum Replies Last Post
Import AS400 formated text into InDesign? Braasch Windows Software 3 16-07-2010 04:38 PM
Import a text file in JTextPane Ash maker Software Development 5 22-01-2010 11:17 AM
How to Import all text data in Excel spreadsheet racer Tips & Tweaks 1 06-01-2010 10:38 PM
import text file into ms access Clay Aiken Windows Software 2 23-06-2009 08:30 PM
Vba import text files Naval Software Development 1 24-03-2009 11:35 PM


All times are GMT +5.5. The time now is 03:04 AM.