I am trying to import a text file via VBA, I have to import via vba as
the file i am importing is not consistently formatted and I also need
to perform some manipulation of the data before it is imported. I am
building an array from a text file and then appending it via DAO.
(Example code below)
I have two problems at the moment firstly every field I import could be
empty so I am having to wrap each field in
If strarray(n) <> "" - is there an easier way of doing this?
Also I am getting a subscript out of range error when it tries to
append strarray(10) - does anyone know why this is happening?
Set RS1 = CurrentDb.OpenRecordset("tblTEMPVendors", dbOpenTable)
FP1 = FreeFile
Open Sourcefile For Input As FP1
Do Until EOF(FP1)
Line Input #FP1, strData
strArray = Split(strData, vbTab)
If Not strData = "" Then 'exclude gaps in header
If Len(strArray(0)) = 0 Then 'exclude report title in line 1
If Not strArray(1) = "Vendor" Then 'exclude column heading
RS1.AddNew
If strArray(1) <> "" Then
RS1.Fields(0).Value = strArray(1)
End If
If strArray(2) <> "" Then
RS1.Fields(1).Value = strArray(2)
End If
RS1.Update 5 6042
show us the definition of strArray()? Is it
Dim strArray(1 to 10)?
or
Dim strArray(10)?
if you used the latter, the index goes from 0 to 9, not 1 to 10. pi********@hotmail.com wrote: show us the definition of strArray()? Is it
Dim strArray(1 to 10)?
or
Dim strArray(10)?
if you used the latter, the index goes from 0 to 9, not 1 to 10.
Actually it will go from 0 to 10, giving 100 elements.
--
This sig left intentionally blank
Trevor Best wrote: pi********@hotmail.com wrote:
show us the definition of strArray()? Is it
Dim strArray(1 to 10)?
or
Dim strArray(10)?
if you used the latter, the index goes from 0 to 9, not 1 to 10.
Actually it will go from 0 to 10, giving 100 elements.
Don't you mean "giving 11 elements"? Single dimension array, right?
0 to 10: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10
--
MGFoster:::mgf00 <at> earthlink <decimal-point> net
Oakland, CA (USA)
MGFoster wrote: Trevor Best wrote:
pi********@hotmail.com wrote:
show us the definition of strArray()? Is it
Dim strArray(1 to 10)?
or
Dim strArray(10)?
if you used the latter, the index goes from 0 to 9, not 1 to 10.
Actually it will go from 0 to 10, giving 100 elements.
Don't you mean "giving 11 elements"? Single dimension array, right?
0 to 10: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10
Um yes, 100 was a typo, still on my first cup of tea today :-)
--
This sig left intentionally blank This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Chris |
last post by:
Background: I am using a MS Access 2000 front end with SQL Server 8.0
back end.
I have the requirement to import all text files (regardless of
filename) from a given folder on the network into a...
|
by: DCM Fan |
last post by:
Access 2K, SP3 on Windows 2K, SP4
All,
I have an import spec set up with quoted Identifiers and comma-separated
values. The text file is produced by a 3rd-party program of which I have no...
|
by: mark |
last post by:
In Access 2000 and 2002, I have created an import specification to import the
fixed-width recordset below into an existing table. I am having strange
problems with the import of the date and time...
|
by: Dan |
last post by:
Could someone please help me with auto importing a series of data
files into an Access table. I tried to follow code given below in a
previous messagebut i'm getting error messages.
Here's my...
|
by: Johnny Meredith |
last post by:
I have seven huge fixed width text file that I need to import to Access.
They contain headers, subtotals, etc. that are not needed. There is also
some corrupt data that we know about and can...
|
by: Steve Jorgensen |
last post by:
I'm restarting this thread with a different focus.
The project I'm working on now id coming along and will be made to work, and
it's too late to start over with a new strategy. Still, I'm not...
|
by: deko |
last post by:
I've been trying to use the Access Import Wizard to expedite importing data
into my mdb. The nice thing about the wizard is that I can import from
different file formats - txt, xls, even Outlook -...
|
by: Bruce W. Roeser |
last post by:
All,
I'm reading a book by Charles Petzold (Programming VS.Net). Pretty good
content but am confused about the difference. From the text:
...
|
by: ghadley_00 |
last post by:
Hi,
I have a MS access database table for which I regularly need to import
fixed width text data. At present I have to to cut and paste the text
data from its source to a text file, save the...
|
by: NewbieSupreme |
last post by:
I'm using PHPMyAdmin on an Apache2Triad install (latest version; 5.x.x,
which installs PHP5 and PHPMyAdmin 2.8 as well). In Access, I exported a
table to a text file, tab-delimited, text qualifyer...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
| |