Question about Microsoft Access 2003 for PC

1 Answer

Unable to import text file to access table

Hey everyone. I have a challenge here that I should be able to figure out but I can't. I'm trying to use the VBA script below to import a text flat file into an existing access db table. Problem is, I can't seem to match the table fields to whats coming from the text file. Can anyone give me a hand?
Dim MyDB As DAO.Database, MyRec As DAO.Recordset
Dim MyList As String
Set MyDB = CurrentDb
Set MyRec = MyDB.OpenRecordset(''Select * From FlatFileImport'')

Dim filnam As String, s As String, MyLine As String, MyLocation As Long, ch As String
Dim once As Boolean

'filnam = ''C:Upload8507CTINC.txt''
filnam = Me![Text2]
Set MyRec = MyDB.OpenRecordset(''Select * From FlatFileImport'')
once = False
If Not IsNull(Me.Text2) Then filnam = Me.Text2
Open filnam For Binary As #1
MyLine = ''''
MyLocation = 0
Do While MyLocation < LOF(1)
ch = Input(99, #1)
If once Then
MyRec.AddNew
MyRec.Fields(1) = Mid(MyLine, 2, 2)
'MyRec.Fields(2) = Mid(MyLine, 3, 3)
MyRec.Fields(3) = Mid(MyLine, 6, 2)
MyRec.Fields(4) = Mid(MyLine, 8, 13)
'MyRec.Fields(5) = Mid(MyLine, 21, 5)
'MyRec.Fields(6) = Mid(MyLine, 26, 15)
'MyRec.Fields(7) = Mid(MyLine, 48, 6)
'MyRec.Fields(7) = '''' & Mid(MyLine, 48, 2) & ''/'' & Mid(MyLine, 50, 2) & ''/'' & Mid(MyLine, 52, 2) & ''''
'MyRec.Fields(8) = Mid(MyLine, 55, 5)
'MyRec.Fields(9) = Mid(MyLine, 62, 4)
'MyRec.Fields(10) = Mid(MyLine, 66, 5)
MyRec.Fields(11) = Mid(MyLine, 8, 8)
End If

once = True
MyLine = ''''
MyLine = MyLine & ch
MyLocation = Loc(1)
Loop

MsgBox '' File has been successfully imported! ''
Close #1 ' Close file.
MyRec.Close
Set MyRec = Nothing

Posted by on

Ad

1 Answer

  • Level 1:

    An expert who has achieved level 1.

    Problem Solver:

    An expert who has answered 5 questions.

  • Contributor
  • 1 Answer

Hey everyone, I was able to fix my problem using the following:

filnam = Me![Text2]
Set objFile = CreateObject("Scripting.FileSystemObject")
Set objText = objFile.OpenTextFile(filnam)
Set rs = CurrentDb.OpenRecordset("FlatFileImport")
once = False
If Not IsNull(Me.Text2) Then filnam = Me.Text2
Open filnam For Binary As #1
Do While Not objText.AtEndOfStream
strTextLine = objText.Readline
Data = Split(strTextLine, ",")
If once Then
rs.AddNew
rs.Fields(1) = Data(0) 'Site ID
rs.Fields(2) = Data(1) 'Client ID
rs.Fields(3) = Data(2) 'Client Name
rs.Fields(4) = Data(3) 'DDA Account
rs.Fields(5) = Data(4) 'Process Date
rs.Fields(6) = Data(5) 'Good Checks Singles
rs.Fields(7) = Data(6) 'Good Checks Stubs
rs.Fields(8) = Data(7) 'Good Checks Partial
rs.Fields(9) = Data(8) 'Good Stubs Partial
rs.Fields(10) = Data(9) 'Good Checks Multi
rs.Fields(11) = Data(10) 'Good Stubs Multi
rs.Fields(12) = Data(11) 'Check Only Checks
rs.Fields(13) = Data(12) 'Check Only Stubs
rs.Fields(14) = Data(13) 'Check And List Stubs
rs.Fields(15) = Data(14) 'Check And List Checks
rs.Fields(16) = Data(15) 'Suspense Checks
rs.Fields(17) = Data(16) 'Suspense Stubs
rs.Fields(18) = Data(17) 'Correspondence
rs.Fields(19) = Data(18) 'Envelopes
rs.Fields(20) = Data(19) 'Express Mail
rs.Fields(21) = Data(20) 'Lookup Stubs
rs.Fields(22) = Data(21) 'Online Lookups
rs.Fields(23) = Data(22) 'Stubs Only
rs.Fields(24) = Data(23) 'StopFile Hits
rs.Fields(25) = Data(24) 'SLC
rs.Fields(26) = Data(25) 'SL2
rs.Fields(27) = Data(26) 'MICR Scanline
rs.Fields(28) = Data(27) 'KeyStrokes Correspondence
rs.Fields(29) = Data(28) 'Keystrokes SLC
rs.Fields(30) = Data(29) 'Keystrokes SL2
rs.Fields(39) = Data(38) 'Exception Queue
rs.Fields(40) = Data(39) 'COA Queue


'IMAGE ARCHIVE ITEMS
rs.Fields(41) = Data(40) 'Image Archive Reports
rs.Fields(42) = Data(41) 'Image Archive Storage

'BATCHES PROCESSED
rs.Fields(43) = Data(42) 'Batches Processed

'ARC ITEMS
rs.Fields(44) = Data(43) 'Low Speed ARC Attempts
rs.Fields(45) = Data(44) 'High Speed ARC Attempts
rs.Fields(46) = Data(45) 'Low Speed ARC Converted
rs.Fields(47) = Data(46) 'High Speed ARC Converted

'ICL ITEMS
rs.Fields(48) = Data(47) 'ICL Attempts
rs.Fields(49) = Data(48) 'ICL Converted
rs.Fields(50) = Data(49) 'ICL Non-Conforming images

'RETURN ITEMS
rs.Fields(51) = Data(50) 'Auto Returns
rs.Fields(52) = Data(51) 'Returned Items

'POSITIVE POST (CDM) ITEMS
rs.Fields(53) = Data(52) 'Positive Post Checks
rs.Fields(54) = Data(53) 'Positive Post Stubs

'REMOTE PAYMENT CAPTURE ITEMS
rs.Fields(55) = Data(54) 'Remote Payment Single Checks
rs.Fields(56) = Data(55) 'Remote Payment Single Stubs
rs.Fields(57) = Data(56) 'Remote Payment Multi Checks
rs.Fields(58) = Data(57) 'Remote Payment Multi Stubs
rs.Fields(59) = Data(58) 'Remote Payment Check Only Checks
rs.Fields(60) = Data(59) 'Remote Payment Check Only Stubs
rs.Fields(61) = Data(60) 'Remote Payment Check & List Checks
rs.Fields(62) = Data(61) 'Remote Payment Check & List Stubs

'DOLLAR DEPOSTIED & PP CORRO REJECT ITEMS
rs.Fields(71) = Data(70) 'Dollars Deposited
rs.Fields(72) = Data(71) 'PP Corro Rejects



rs.Update
End If

once = True
MyLine = ""
MyLine = MyLine & ch
MyLocation = Loc(1)
Loop
MsgBox " File has been successfully imported! "
Close #1 ' Close file.
rs.Close
'close and erase the file from memory
objText.Close
Set objText = Nothing
Set rs = Nothing

Posted on Sep 09, 2009

Ad

1 Suggested Answer

6ya6ya
  • 2 Answers

SOURCE: I have freestanding Series 8 dishwasher. Lately during the filling cycle water hammer is occurring. How can this be resolved

Hi,
a 6ya expert can help you resolve that issue over the phone in a minute or two.
Best thing about this new service is that you are never placed on hold and get to talk to real repairmen in the US.
the service is completely free and covers almost anything you can think of.(from cars to computers, handyman, and even drones)
click here to download the app (for users in the US for now) and get all the help you need.
Goodluck!

Posted on Jan 02, 2017

Ad

Add Your Answer

Uploading: 0%

my-video-file.mp4

Complete. Click "Add" to insert your video. Add

×

Loading...
Loading...

Related Questions:

1 Answer

Properties in importing excel table to an access table


This article explains how to import a Microsoft Excel file into Microsoft Access version 2.0 or 7.0. Microsoft Access can import files from Microsoft Excel version 2.0 through version 7.0. However, Microsoft Access cannot import Microsoft Excel 4.0 workbooks (.xlw). This article assumes that the Microsoft Excel file is using standard database formatting. That is:

To import a Microsoft Excel file in Microsoft Access 2.0 loadTOCNode(2, 'moreinformation');
  1. Save the file in Microsoft Excel using standard database formatting listed above. Close the file.
  2. Start Microsoft Access 2.0 and open the database you want to import the Microsoft Excel information into.
  3. On the File menu, click Import. From the Import dialog box, choose the appropriate version of Microsoft Excel that you are importing and click the OK button. Microsoft Excel 7.0 files are not on this list. If you are importing a version 7.0 file, choose the Microsoft Excel 5.0 option.
At this point options such as whether to append to an existing table or create a new table may be selected.
To import a Microsoft Excel file in Microsoft Access 7.0 loadTOCNode(2, 'moreinformation');
  1. Save the file in Microsoft Excel using standard database formatting listed above. Close the file.
  2. Start Microsoft Access 7.0 and open the database you want to import the Microsoft Excel information into.
  3. On the File menu, click Get External Data and then click Import.
  4. From the import dialog box, choose Microsoft Excel (*.xls) for the Files Of Type option.

    This will display only the Microsoft Excel files.
  5. Find the desired file and click the Import button.
The Import Spreadsheet Wizard appears and allows you to choose options specific to the file.

or you just use the link for any problem where you can get details of the importing
http://www.techrepublic.com/article/techniques-for-successfully-importing-excel-data-into-access/5276622

May 05, 2011 | Computers & Internet

1 Answer

Want to import email addresses into MS Outlook


Hey! follow the steps to get your job done


You can import address book contacts from other Microsoft Windows® Address Book files (.wab), as well as from Netscape Communicator, Microsoft Exchange Personal Address Book, or any text (.csv) file.
For Windows Address Book 1.
On the File menu, point to Import, and then click Address Book.
2.
Select the address book or file type you want to import, and then click Open.

For All Other Address Book Formats 1.
On the File menu, point to Import, and then click Other Address Book.
2.
Click the address book or file type you want to import, and then click Open.

If your address book is not listed, you can export it to either a text (.csv) file or a Lightweight Directory Access Protocol (LDAP) or Lightweight Directory Interchange Format (LDIF) file, and then import it using that file type.



Good luck :-)

May 27, 2010 | Microsoft Windows XP Home Edition

7 Answers

Undelete records from access table


ou can try to use third party Access recovery utility to restore your lost and damaged data from .mdb files. For more details about this software:-
Access File Recovery

Apr 17, 2009 | Microsoft Access 2000 (077-01277) for PC

2 Answers

Steps in saving file in excel to database


severals solution :
- save file as text separated by comma and use sqloader from oracle
- use function in excel to concatenate insert order : "insert into TABLE_NAME (field1,...,fieldn) values (A1,B1,...,??n);". Save file as text with sql extension. Connect against roacle db and execute file previously saved.
- use ODBC from MicroSoft

Dec 11, 2008 | Microsoft Computers & Internet

1 Answer

Code for find the Ms access database size using visual basic


The way to get the database size is to point to the directory that the database is do a DIR statement with an output to a file as in DIR payroll.mdb>dbsize.txt and then read from the text file, the first field of the second line being the name (which you really don't need) then the size value of the database.

To import the text files using VB 8 use

'Imports System.Data.OleDb Dim conn As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=d:\path\filename.mdb") Dim cmd As New OleDbCommand("SELECT * INTO [import] FROM [Text;Database=d:\path;Hdr=No].[dbsize.txt]", conn) conn.Open() cmd.ExecuteNonQuery() conn.Close()

Nov 10, 2008 | Microsoft Office Standard for PC

1 Answer

Import Database - No tables


Your table may be open in another application. Try closing the database or file, and then try to the import process again.

Oct 29, 2008 | Synercard Asure ID Enterprise (932011001)...

1 Answer

DOS Programme to txt file


Assuming that you are not able to export the data from the
original point of sale application, which is obviously the
best choice...

1)
Try to open the file(s) with Microsoft Excel (make sure that all of Excel's input conversion filters have been installed and enabled).

Most database files are organized as a set of (nested)
two dimensional data tables, which can be individually
imported into Excel as spread sheets.

Excel is very good at detecting and converting database tables.
Other spread sheets such as Lotus 123, or Quatro pro may also
be able to do this.

2) Microsoft Access may also be capable of importing
and converting the entire database.

3) Heavy duty data-base modeling suites, such as ER-Win
by Computer Associates (CA) may also be able to import
and export the database.

4) If the files are in the open *.dbf format, then I have the binary
file specifications, which can be used to decipher the files.

5) The files may also be simple tables, which are TAB, SPACE,
or COMMA (etc.) delimited, and you should be able to recover
these with a simple notepad editor or uuedit.

6) Most DOS programs (not all) can also be run under Windows
XP, using the command prompt:

START ==> All programs ==> Accessories ==>
Command Prompt.

========================================
Most importantly, we need to know the name of the application
that created the files, or see a sample of the file, to give you
further advice.

Martin

May 07, 2008 | Computers & Internet

3 Answers

Access 2000 database won't compact and repair.


mchampion,

You are in luck. I had the same problem a while back. Most of the time you will not be able to compact and repair a database that has reached capacity, however, you can import the database into a new one. The first thing you are going to have to do is find a very large table in your database and copy it into a new one. Then, delete that table from your old database. Now, open another new database. Go to the file menu and choose import. Now you must find your database in the directory and click it. Now choose one of the given options (tables, queries, etc.). Then, Press control + a to select all items. Now hit okay and it will import all of the items from your old database from that section into the new one. You must do this for each section (tables, queries, etc.). When everything is imported (should take less than an hour), compact and repar the new database. This will give you additional space to work with. Now you can bring in the table that you copied into a new database earlier the same way (import). This should put you back in business.
I suggest creating a 2nd database for any other data you may want to add later. You can always make link tables and such in your old database in order to get the additional data and prevent crashing your old database.
Let me know if you need any additional help.

ArthurB

Apr 24, 2008 | Computers & Internet

1 Answer

Dreamweaver CS3


Import Microsoft Office documents (Windows only) You can insert the full contents of a Microsoft Word or Excel document in a new or existing web page. When you import a Word or Excel document, Dreamweaver receives the converted HTML and inserts it into your web page. The file’s size, after Dreamweaver receives the converted HTML, must be less than 300K.
Instead of importing the entire contents of a file, you can also paste portions of a Word document and preserve the formatting.
Note: If you use Microsoft Office 97, you cannot import the contents of a Word or Excel document; you must insert a link to the document.
  1. Open the web page into which you want to insert the Word or Excel document.
  2. In Design view, do one of the following to select the file:
    • Drag the file from its current location to the page where you want the content to appear.
    • Select File > Import > Word Document or File > Import > Excel Document.
  3. In the Insert Document dialog box, browse to the file you want to add, select any of the formatting options from the Formatting pop-up menu at the bottom of the dialog box, and then click Open. Text Only Inserts unformatted text. If the original text is formatted, all formatting will be removed.
    Text With Structure Inserts text that retains structure, but does not retain basic formatting. For example, you can paste text and retain the structure of paragraphs, lists, and tables, without retaining bold, italics, and other formatting.
    Text With Structure Plus Basic Formatting Inserts both structured and simple HTML-formatted text (e.g., paragraphs and tables, as well as text formatted with the b, i, u, strong, em, hr, abbr, or acronym tag).
    Text With Structure Plus Full Formatting Inserts text that retains all structure, HTML formatting, and CSS styles.
    Clean Up Word Paragraph Spacing Eliminates extra space between paragraphs when you paste your text if you selected Text With Structure or Basic Formatting. The contents of the Word or Excel document appear in your page.
Source: Dreamweaver CS3 Help

Feb 06, 2008 | Adobe Photoshop 7.0 for PC

1 Answer

Restriction on import of forms and tables in msaccess


I could not understand the 1st question clearly.
as for the second question you can download microsoft viewers for any office product at their site. they can view files only.

Jan 29, 2008 | Computers & Internet

Not finding what you are looking for?
Microsoft Access 2003 for PC Logo

184 people viewed this question

Ask a Question

Usually answered in minutes!

Top Microsoft Computers & Internet Experts

micky dee

Level 3 Expert

2888 Answers

Piyal Perera
Piyal Perera

Level 3 Expert

528 Answers

Les Dickinson
Les Dickinson

Level 3 Expert

18409 Answers

Are you a Microsoft Computer and Internet Expert? Answer questions, earn points and help others

Answer questions

Manuals & User Guides

Loading...