Results 1 to 3 of 3

Thread: How to import Text into Access through VBA

  1. #1
    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.

  2. #2
    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.

  3. #3
    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"

Similar Threads

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

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,713,990,726.92565 seconds with 16 queries