Cornfused said:
Yes, I would like Access to perform a find function in Notepad. The ID for
each record is displayed in an form, and I would like Access to take that
ID
and locate it within the report. Once located, the audit will take place
by
manually comparing the report to information displayed in a third window,
IE.
In essence, what I'm trying to do is elimenate manual activity in one of
the
three windows. It seems logical that Notepad, since it is only for
reference, would be most easily automated to display the record that is
currently displayed within the Access form.
Below is your requested sample: (6910 would be the text to find in this
case)
6910 "Name of Individual" Date: 04/05/05
-----Scheduled----- ------Actual------- Scheduled Actual
Variance
From To Dur. From To Dur. Activity Activity
Description
----- ----- ----- ----- ----- ----- --------------------
-------------------- ---------------------------------------------------------
--:-- --:-- --:-- 12:30 12:31 00:01 Unstaff
Unscheduled event
12:30 13:30 01:00 --:-- --:-- --:-- Open Time
--:-- --:-- --:-- 12:31 13:31 01:00 Logon
Unscheduled event
13:30 14:00 00:30 --:-- --:-- --:-- Pre-Sched follow ups
As I've already suggested, you can use the VBA approach and read everything
into a text variable.
Once it's in the text variable, you can find the occurrence of 6910, and
find the first occurrence of Pre-Sched follow ups after that. Once you know
that, you can create a substring of the text and display it in a field in
your form, something like the following untested air-code:
Dim intFile As Integer
Dim lngFileSize As Long
Dim lngStart As Long
Dim lngStop As Long
Dim strAllText As String
Dim strFile As String
Dim strSpecific As String
Dim strToFind As String
' Set the person to find.
' Note that I'm putting a space after the value to minimize
' false finds. If you know there will be a space in front, use
' it as well, so that you'll only find what was between the spaces.
strToFind = "6910 "
' Make sure strFile actually exists
If Len(Dir$(strFile)) > 0 Then
' Determine how big the file is
lngFileSize = FileLen(strFile)
' Determine the next available FreeFile tag
' and open the file
intFile = FreeFile
Open strFile For Binary As intFile
' Initialize the variable to be big enough to contain the file,
' then read the entire file into the variable
strAllText = Space(lngFileSize)
Get #intFile, , strAllText
Close intFreeFile
' At this point, strAllText contains the entire content of the file
lngStart = InStr(strAllText, strToFind)
If lngStart > 0 Then
' Person was found at the position indicated by lngStart
lngStop = InStr(lngStart + 1, strAllText, "Pre-Sched follow ups",
1)
If lngStop > 0 then
' End phrase found starting at the position indicated by lngStop.
' Let's put everything in between into strSpecific.
' Note that you need to add 20 to lngStop since that's how much text
' is in the string for which we were searching
strSpecific = Mid$(strAllText, lngStart, (lngStop + 20) -
lngStart + 1))
Else
' End phrase not found: don't know what you want to do...
strSpecific = strToFind & " found, but end phrase wasn't"
Else
Else
' Person was not found in the text
strSpecific = strToFind & " was not found."
End If
End If
' Put either the found text, or the message into the form's field
Me.txtOutput = strSpecific
HTH.