John, being relatively weak in VBA, no experience in Perl, and not having
success with Word (and needing to get this process as automated as possible
by tuesday morning) I posted a question in VBA Programming that would copy
values down a column until it hit the next column that was not null. There by
I would have a key that would link the data that was spread across the 4
rows. Whenever I attempted to provide an example, this news group would shift
the location "cardio" to a fifth row under the Patient Identifier. which is
not the case (and why I tried to post a couple of clarifications after the
fact)
So...while it was related to our original posting on Import/Export group, I
was asking for help for a VBA solution that I think I would be able to manage
given my level of experience. (ie...a button that would run code to copy the
Patient # and then loop until the end of the table)
If you look at the example I ask for VBA code that would go from the first
example to what I have in the second example... (From this...To This). The
secod example, where the Patient number is repeated across the rows is not
meant to indicate what the file looks like now..just where I want to go.
So...for example purposes for the easier VBA solution I thougt I could handle
, you can omit the Field 5 and the word Cardiology all together and take that
to mean what the current file looks like.
So, My VBA question example is going from this.....
Field1 Field2 Field3 Field4
M000999999 MORA,EDUARDO N M/30
07/05/05
1440
M000123456 GARCIA,HOPE J F/80
07/05/05
1000
To this........
Field1 Field2 Field3 Field4
M000999999 MORA,EDUARDO N M/30
M000999999 07/05/05
M000999999 1440
M000123456 GARCIA,HOPE J F/80
M000123456 07/05/05
M000123456 1000
Sorry for the confusion. Still would appreciate any suggestions.
Antonio
> Antonio, almost every message you have posted, both here and in
> ..externaldata, shows a different structure of the sample data. It now
[quoted text clipped - 110 lines]
>
> Please respond in the newgroup and not by email.
John Nurick - 04 Jul 2005 07:18 GMT
Here is an "air code" VBA procedure which shows one approach to the
problem. It assumes among other things that every record has the same
number of lines in the same order, and that the padding between fields
in the text file consists of spaces.
Function XX()
Dim lngFN As Long
Dim strLine As String
Dim strF1 As String
Dim strF2 As String
Dim strF3 As String
Dim strF4 As String
Dim strF5 As String
Dim rsR As DAO.Recordset
Set rsR = CurrentDb.OpenRecordset("My Table")
lngFN = FreeFile()
Open "C:\Folder\file.txt" For Input As lngFN
Do Until EOF(lngFN)
Line Input #lngFN, strLine 'read first line
strLine = Trim(strLine)
strF1 = Left(strLine, InStr(strLine, " ") - 1)
strF2 = Trim(Mid(strLine, InStr(strLine, " ")))
Line Input #lngFN, strLine 'read second line
strF3 = Trim(strLine)
'repeat for lines 3 & 4 (and any others)
'...
With rsR 'add record to table
.AddNew
.Fields(0).Value = strF1
.Fields(1).Value = strF2
'and so on
.Update
End With
Loop
rsR.Close
Close #lngFN
End Function
>John, being relatively weak in VBA, no experience in Perl, and not having
>success with Word (and needing to get this process as automated as possible
[quoted text clipped - 153 lines]
>>
>> Please respond in the newgroup and not by email.
--
John Nurick [Microsoft Access MVP]
Please respond in the newgroup and not by email.
Antonio - 05 Jul 2005 12:14 GMT
John, thank you for the help. It did the trick and I've met my deadline.
Again, sorry for the confusion. I appreciate all you have done.
Antonio
> Here is an "air code" VBA procedure which shows one approach to the
> problem. It assumes among other things that every record has the same
[quoted text clipped - 204 lines]
>
> Please respond in the newgroup and not by email.