I am reading the text file and it works fine, until a start of string is not present. In that case it begins at start of text file and inserts all data to end point.
For example: ![TypeOfService] = getValue(strCon tent, 104, 105)
If there is no "104" in the file, it begins at beginning and copies all data to the end point of 105.
I hope I explained this clearly. I attempted on Line 41 but, I...
User Profile
Collapse
-
How skip to next line?
-
Thanks, as always you educate me. The error was invalid argument -
why does this error out at last line
...Code:Public Function getValue(strInput As String, lngStart As Long, Optional lngEnd As Long = 0) 'Get starting location Dim lngPosStart As Long Dim strStart As String strStart = vbCrLf & lngStart & "." lngPosStart = InStr(1, strInput, strStart) + Len(strStart) 'Get end location (if any) Dim lngPosEnd As Long If lngEnd -
Thank you sir for your reply-I am fairly new at the VBA side of access. I tried what you said and I still get compile errors. I am just trying to import a text file-the complete code is attached. Can you tell me what is wrong with this code (I know I need to correct the heart)Thanks in advance
...Code:Option Compare Database Option Explicit Public Function readFile(Optional strPath As String) As String 'CreateLeave a comment:
-
compile errors Expected expression
I have received alot of help from this site and I am grateful. My problem is that I was able to get the first part of code to work. I tested it via the immediate window. I received the compile error "expected expression" when I tested for function InputFile.
?InputFile(Opti onal strPath As String)
"expected expression"
?InputFile()
"expected function or variable"
Below is the...Last edited by Dormilich; Mar 4 '11, 10:50 AM. Reason: please use [CODE] [/CODE] tags when posting code -
I took your advice and researched a bit-I receive a argument is not optional error when I call this. For instance referring to code below:
Call InputFile (should there be a variable here)as I believe the procedure is looking for one. Am I still off target?
Public Sub InputFile(strPa th As String)
Dim strContent As String
strPath = "C:\Users\Jeff\ Desktop\TcossDo cument.txt"...Leave a comment:
-
I agree with you and I thank you very much for your assistance and patience. Be blessedLeave a comment:
-
I am sorry just to understand the code should look like this
Public Function readFile(strPat h As String) As String
'Create a filesystemobjec t
Dim fso As Object
Set fso =
CreateObject("s cripting.filesy stemobject")
'Open file for reading
Dim strFileContent As String
strFileContent = readFile("C:\Im portFiles\myFil e.txt")...Leave a comment:
-
I understood that it is not complete-I was trying to get it to read file-I assumed I was coding it wrong as to why I was getting compile error (the function or sub not defined) I was only working with the read portion of codeLeave a comment:
-
I must being doing something wrong-I pasted the code in ACCESS but I continue to get an error. Sub or Function not defined. I am just learning this aspect of access, please be patient. Should I replace strPath with location of file?Leave a comment:
-
Thank you very much-it is greatly appreciated. I must being doing something wrong-I pasted the code in ACCESS but I continue to get an error. Sub or Function not defined. I am just learning this aspect of access, please be patient. Should I replace strPath with location of file?Leave a comment:
-
I will receive a new file every time so it will need to appendLeave a comment:
-
Thank You for your quick response-Can you show or guide me how I would write the first line to create the table aspect. I can follow after that
Basically when it is read into access I want a table that
that has fields named [TSR Number] [Type Action][TYPE OF SERVICE][NETWORK REQUIREMENTS] and the corresponding information from the text in that field i.e. After reading the text [TSR Number] would have "EJ13JAN102 064"...Leave a comment:
-
How to import text file to access and assign value to table?
I have a text file that I want to read and assign parts to a certain field in MS Access table
When you look at this file you will see numbers with corresponding info Ex: 120A. CMPBLLBK I want to have 120A be called “Location” and “CMPBLLBK” be populated in that location.
Basically when it is read into access I want a table that
that has fields named [TSR Number] [Type Action][TYPE OF SERVICE][NETWORK...
No activity results to display
Show More
Leave a comment: