Modules & VBA :: How To Read TXT File Into Array For Processing
Oct 23, 2014
I'm getting an error when trying to read a .txt file into an array for processing. The error and a snippet of the code are below.
Run-time error '9'
Subscript out of range
Dim iFileNum As String
Dim strLineInfo()
Dim i As Integer
Dim strExpensesFile As String
strExpensesFile = "c:FinanceExpensesIn.Txt"
[Code] .....
View Replies
ADVERTISEMENT
Jun 9, 2013
I'm trying to parse the following into an Array by splitting the csv file using a "," comma separator. There should be 63 different data pieces in this File. When I do a count of them from the (ubound array) i only get 54. The last data piece on each row gets concatenated to the first data piece of the next line. Is there a way to stop this from happening? This is causing problems with working with the data.
Date,Open,High,Low,Close,Volume,Adj Close
2013-06-07,1625.27,1644.40,1625.27,1643.38,3371990000,1643 .38
2013-06-06,1609.29,1622.56,1598.23,1622.56,3547380000,1622 .56
2013-06-05,1629.05,1629.31,1607.09,1608.90,3632350000,1608 .90
2013-06-04,1640.73,1646.53,1623.62,1631.38,3653840000,1631 .38
2013-06-03,1631.71,1640.42,1622.72,1640.42,3952070000,1640 .42
2013-05-31,1652.13,1658.99,1630.74,1630.74,4099600000,1630 .74
2013-05-30,1649.14,1661.91,1648.61,1654.41,3498620000,1654 .41
2013-05-29,1656.57,1656.57,1640.05,1648.36,3587140000,1648 .36
View 3 Replies
View Related
Nov 5, 2013
I have a text file that I am using VBA to read and print 2 pieces of data to another text file.The code works to a point, in some instances it does not appear to find the end of file but captures and writes all the data. Or, after printing 36 lines correctly, it then stops writing.
I have stepped through the code and it appears to be capturing the data up past this issue but for what ever reason it does not print it to my text file.
PHP Code:
Option Compare DatabaseOption Explicit    Public Mode As String    Public FUNDREF As String   Â
Public rst As String Function DAILYAUDITTRAIL()     Close #1    Close #2      Open "C:UsersTEST IN.TXT" For Input As #1   Â
Open "C:UsersTEST OUT.txt" For Output As # 2      Do While Not EOF(1)    Â
Line Input #1, rst     If rst Like "KM56Aasdf*" Then        FUNDFINDER   Â
End If     Loop  End FunctionFunction FUNDFINDER()         Â
[code]...
View 3 Replies
View Related
Oct 8, 2013
For weeks I am trying to read an XML file which needs to be processed in an Access database. I can not find the proper way to:
- find a specific node
- iterate from there
The XML file is an international bank file:
Code:
<?xml version="1.0" encoding="utf-8"?>
<Document xmlns="urn:iso:std:iso:20022:tech:xsd:pain.008.001.02" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<GrpHdr>
<MsgId>001-2013-09-19-18:12:17</MsgId>
[Code] ....
I started quite simple, just wanted to read to node MsgId. This is the code I use:
Private Sub ReadXML_Click()
Dim aDoc As DOMDocument60
Dim aNode As IXMLDOMNode
Set aDoc = New MSXML2.DOMDocument60
aDoc.async = False
aDoc.Load DLookup("C:Sample.XML")
[Code] ....
Whatever I try: //MsgId or MsgId the results is "No nodes". How to read to XML.
Besides reading one node, the next challenge will be iterating the PmtInf node. There can be 1 in the XML file but also 50.
View 12 Replies
View Related
Feb 26, 2014
I have an access program that is stored on a SharePoint site. I want to be able to export report to the computer even if I just open the access program as read only. Here's my code:
Code:
Private Sub btnExport_Click()
On Error GoTo btnExport_Click_Err
Dim db As DAO.Database
Dim strSQL As String
Dim qdfTemp As DAO.QueryDef
Dim qryFilter As DAO.QueryDef
[code]...
View 2 Replies
View Related
Mar 26, 2013
I have an excel file that I need to prepare to create a report.It would be great if I could do this with Access 2003. This would mean that I need to import the excel file and create a table to handle this.Is there by any chance that I don't need to create a table and I can process the excel file? Or maybe automate the import of the excel file into table and only use a few of the columns so later I can create the report in access.Also what I need to do is add some columns with text in it (a standard text) that needs to add a day taken form the column to the right.
I simply would like to avoid to create a table from the import as this would make me end with a lot of tables (or mabye option to delete the table after finishing producing the report.
View 1 Replies
View Related
Nov 29, 2014
I have a module which reads a CSV transaction file line by line and adds the correct transactions to an access table and places the wrong ones in a logfile.Now some transactions are rejected twice there is even one rejected six times. Whereas one wrong transaction is processed only once. I am certainly overlooking something obvious in the logic but what. Here is the relevant code.
Code:
Function ImportCSVForConfederation(inputCSV, ORG)
Dim TNO As Integer, TACT As Integer, TABLE As String, TLINE As String, I As Integer, J As Integer, K As Integer
Dim FLD1 As String, FLD2 As String, FLD3 As String, FLD4 As String, LogFile As String, LogPath As String
Dim Lim As String, ITNO As Integer
[code]....
View 8 Replies
View Related
Jan 16, 2014
I'm trying to setup a process of opening a form, saving to a location, emailing it as a PDF, killing the PDF, move onto the next form - rinse wash repeat until done.The below works fine on a single click, however if I try to set it as an event timer of loop, I get an error saying: This action cannot be carried out whilst processing a form or report event.
Do
Dim outputFileName, Ref As String
Ref = Vici_URN
outputFileName = CurrentProject.Path & "Claim PackagesCICA" & Ref & " - " & Format(Date, "yyyyMMdd") & ".pdf"
[code]..
View 1 Replies
View Related
Oct 19, 2006
I'm using Access 2000. When I click the File menu to go to a recently used file, the entire path is shown. With my file system, the File drop down widow is about 50 characters too short to show the entire path all the way out to where I keep my database. Is there a way to shut off the viewing the entire path "feature?"
View 2 Replies
View Related
Jan 4, 2005
This is what I would like to achieve
Each time a person comes into our building, they use a electronic key. The information is recorded into a text file. I would like to extract information as described next
The date from the line marked D. Date is marked in bold
The time from the line marked T. Time is marked in bold
The key number and Location from the line marked M. Key Number & Location is Marked in Bold
Sample of the text file:
D[ Fri 30/04/04 ]
T[ 08:19 ]
M[ Valid key:130 Ing group, tenancy:SUNCITY, door:Lower Roller Dr, panel:SURF CITY. ]
N[ 0 2 0 0 5 23 1 0 0 0 130 2 ]
D[ Fri 30/04/04 ]
T[ 08:22 ]
M[ Valid key:20 LEAD NGUYANST, tenancy:SUNCITY, shaft:0, panel:SURF CITY. ]
N[ 0 1 0 0 5 16 1 0 0 0 20 2 ]
D[ Fri 30/04/04 ]
T[ 08:23 ]
M[ Valid key:556 Ing Group, tenancy:SUNCITY, door:Lower Roller Dr, panel:SURF CITY. ]
N[ 0 2 0 0 5 23 1 0 0 0 556 2 ]
…..and so on the text goes
I am reasonably familiar with access but I have not had any experience with Text Files . Could someone post a sample db that would give me a starting point. any information would be appreciated.
Phil.t
View 6 Replies
View Related
Sep 9, 2014
I am way beyond my skills trying to read these files.
I am trying to read *.pdf files using VBA. I have tried using some code
Code:
Dim AcroApp As Acrobat.CAcroApp
Dim theForm As Acrobat.CAcroPDDoc
Dim jso As Object
Dim text1, text2 As String
'error occurs here stating"ActiveX component can't create object"
[Code] ....
I have set a reference to Adobe 10 Type Library and Adobe Access 3 Type library. I am using Adobe Acrobat Reader X. I now read them by converting to text file and using FileObject to read the text file and VBA text commands to get the right fields.
View 9 Replies
View Related
Feb 13, 2014
Let's say I have a database saved in Folder 1. Is there a way for me to create a read-only copy of that database in Folder 2 so that it can be up-to-date with the changes made in the Folder 1 database? I am running Windows 7.
View 10 Replies
View Related
Nov 3, 2005
I have a Front-End Access Data Project file (ADE compiled format for distribution) that I purposely have the Read-Only file attribute set to True.
I've been using it this way for about 7 years starting with Access 97 and the current version is 2000.
I am upgrading the app to 2003 now and everything with the conversion is fine except when I set the Read-Only file attribute to True it all of a sudden when starting it no longer connects to the Back-End (sql server) and displays a "form load cancelled" error before hanging.
If I disable the Read-Only attribute, everything is fine again, but I prefere not to do this because that will require me to rework my auto updater.
I use it this way because it prevents bloating of the file and allows for my auto updater to determine new version by using the file modification date.
Any Idea's?
View 1 Replies
View Related
Apr 3, 2006
Within Access 2000 is there some VBA code i can use to remove the read only status of a MS Excel spreadsheet?
Regards,
Neil
View 1 Replies
View Related
Apr 28, 2015
Is it possible to send several form's OpnArg as Array ? Now I'm using a long text string including || as divider so I can split them later into Array.
View 8 Replies
View Related
Nov 14, 2013
I am having a problem with parsing the array value to Forms!<arraryvaluehere>.dirty.
Please see the code below:
Public strListOfForms(0 To 2) As String
strListOfForms(0) = "frmForm1"
strListOfForms(1) = "frmForm2"
strListOfForms(2) = "frmForm3"
For i = 0 To 2
Debug.Print CurrentProject.AllForms(strListOfForms(i)).IsLoaded
Debug.Print Forms!strListOfForms(i).Dirty
Next i
Note: CurrentProject.AllForms(strListOfForms(i)).IsLoade d works and Forms!strListOfForms(i).Dirty does not.
Is this because it is taking "strListOfForms(i)" literally? Is there a way that I can get around this?
View 1 Replies
View Related
Apr 7, 2014
I have some code that successfully gathers some items and adds these items to a listbox, one item at a time using .AddItem.And it works ok.The problem is, when there are a bunch of items to add, everytime the .AddItem runs, the form redraws.there are a bunch and this leads to a lot of flicking while the form redraws however many times .AddItem adds an item.
I've had the idea of building an array and then assigning the array to the listbox.I can build the arrray no problem but i have not been able to assign the array to the listbox all at once.how to do is add items to the listbox from the array one specific item ListArray(i) at a time.
Obviously this would work, but gains me nothing in terms of the visual effect in the form becuase it is still adding to the listbox one item at a time.Is there some way to assign an array to a list box all at once, without doing it one item at a time?
View 3 Replies
View Related
Jul 1, 2013
How do I delete values in an array? I want to reuse that array but first I need to delete its values so I would start with Arr(0) rather than where I stopped off with the last loop at Arr(10) [assuming the last calculation inserted until Arr(9)]
Here is my code:
Set rst = CurrentDb.OpenRecordset( _
"Select * from dbo_ProductStructure where ChildProductNbr Like '*" & txtPartNumber & "*'") 'search associated fields with user input
While rst.EOF = False
ReDim Preserve Arr(i)
Arr(i) = rst.Fields("ParentProductNbr")
i = i + 1
rst.MoveNext
Wend 'end of while loop
x = Arr
View 9 Replies
View Related
Aug 16, 2013
I'm trying to store all the OrderNumber + Item combinations in 2 arrays and then because the OrderNumber column really contains 2 values I'm interested in, I split it up and store that column's values in 2 arrays. So in total, I have 3 arrays. An array for Item, an array for Order, and an array for RepId (which is the one that I split up from the OrderNumber column).
Anyways, when I print the RepId array with the ' MsgBox PostValCol1(x) ' It prints 4 values like it's supposed to. But when I tested it again by looping through the values and just doing a MsgBox, It goes for a long time and that's because it has a lot of empty values in that array. How to get rid of those empty values/not store them in the first place?
Code:
Set rop = CurrentDb.OpenRecordset("Select OrderNumber, ItemNumber From dbo_EntryStructure Where (ProductNumber = '" & txtPartNumber & "') AND (ActionCode = 'I')")
While rop.EOF = False
ReDim Preserve ArrRepOrder(j)
ReDim Preserve ArrItem(j)
[Code] .....
View 3 Replies
View Related
Mar 11, 2014
I have an Access Database that I will be using on a desktop. I have a table in this database that mirrors the structure of a table on a remote server in a SQL database. I have successfully created a vba function within the Access database that uses a server-side php subroutine to select records (I usually won't know how many) from the SQL database and return them to the access database. The code I use in the access vba subroutine to access the php subroutine is:
Code:
With CreateObject("Shell.Application").Windows
Set ieWindow = CreateObject("InternetExplorer.Application")
ieWindow.Visible = False
apiShowWindow ieWindow.hwnd, SW_MAXIMIZE
ieWindow.Navigate "Web address for server-side php file"
End With
The last command in my php subroutine is "return $retrievedData." $retrievedData is a multidimensional array containing data from 42 fields in multiple records (again, I usually won't know how many). I've checked the data in php so I know it has been stored correctly.how do I access the returned data within my access vba subroutine?
I should add that my overall reason for doing it this way is that I want to maintain my server-side database as an untouched master. Users can only add data to it. My client-side database is used to update the input table and further process the data. The subroutines described above are intended to retrieve "new" records only (i.e., records posted since the last access database update) from the server-side database and transfer them to the access database for further processing.
View 3 Replies
View Related
Aug 1, 2006
I'm currently creating an interface program for a MS Access database. I've only used Access once in the past but used other DB's a handful of times so I didn't have any trouble getting the general program created. My issue arose when I tried to make it so that the users needing to use the program can just copy the .exe and the .mdb files and use it.
The program doesn't require users to share the database but to store their OWN programs information in their OWN database, so basically each needs to have their own database with the exact same design (but different data). The original plan was to just get them to copy over a near empty .mdb with the design set up and have them slowly create their own dataset with it. However, upon copying these files between my computer and others it ends up allowing my interface program to retrieve data from the DB but not write any new entries to it. All security permission on the file itself are set to allow read/write to everyone so I'm not sure what's causing this. Is there any other security settings I should worry about? Everything I could find within access seemed to be set so that it could be used freely so I'm not sure what the problem is. Any help would be greatly appreciated.
P.S. - I apologize if there is already a related topic in existence, I am new to these boards and tried to search beforehand for any information on this topic but came up empty handed so decided to start my own topic about this problem.
View 4 Replies
View Related
Oct 17, 2014
Was wondering how i can import data from a file to a table in different fields. The data inside the file is described with the number of characters and space's between. The attached file has the data.
For example in the file attached, the first four characters represent a data like 'ticket number' and maybe the third line 6 to 10 charcaters represent 'name of a passenger'.
Now how do i import these data to a table into respective fields in a table.
View 14 Replies
View Related
Jun 26, 2014
I have a boolean array, foundState(3), whose 4 elements correspond to 4 variables describing conditions that will dictate what action is taken upon closing a form.
There are only 6 possible outcomes for the array, and they can be divided into just 4 cases:
Case {T,T,T,T}
Case {T,T,T,F} OR {T,T,F,F} OR {T,T,F,T}
Case {T,F,F,F}
Case {F,F,F,F}
What the proper syntax would be for this if I'm trying to create a "Select Case" statement for these 4 cases.
View 7 Replies
View Related
Aug 23, 2013
how I can make an Array and For Each statement work together. I normally don't use either, but it would be good so I could write less code where plausible. Here is the example I have:
Code:
Dim Named As Variant
Dim Ctl As Control
Named = Array(Me.Namee, Me.ID, Me.Title)
[code]....
I am unsure how I include the array in this statement. I have tried replacing "Me.Controls" with the array name, but I get a 424 runtime error (no object). What I am trying to accomplish is for each item in the array I want to make it not visible if it has a null value.
View 7 Replies
View Related
Oct 4, 2014
I have to deal with string arrays that store text. I need info on copying, comparing, appending arrays. Also on passing arrays as parameters to subs or functions. Where I can get to this info quickly without having to browse through many screens.
In addition to this I have some questions:
I have to find the duplicates of values in an array. Here is the code that I use.
Code:
Sub FindDuplicates()
Dim I As Integer, J As Integer, IEND As Integer, text() As String
ReDim text(IEND)
For I = 1 To IEND - 1
For J = I + 1 To IEND
If text(I) = text(J) Then text(J) = ""
Next J
Next I
End Sub
It works but is not performing well. Are there more efficient ways of doing this?
View 14 Replies
View Related
Jul 31, 2014
Now the getrows is working fine at my end. Now I have a different problem at hand:
Sub Test2()
Dim myrset As Recordset
Set myrset = CurrentDb.OpenRecordset("SELECT * FROM Holidays;")
myrset.MoveLast
[Code]....
Recordcount is coming fine
Manual Array is also giving the right result
But the Index method is giving the wrong value. Why?
(Holidays table is just having the values in the array only ie. #08/15/2014# and #08/29/2014#)
View 7 Replies
View Related