DJShaneOOO wrote in message
How do I get Access 2003 to read variable query paramater values from
a text file?
I have a program that outputs a single text file (with one record)
and I want access to read the contents of that file and use it as a
search criteria for the access database
Any help appreciated
What you need, is a public function to retrieve this information. This
public function can be called from the query. Without exactly knowing
why, I'm not comfortable with having a query calling a function which
opens external files. I think I'd rather have a form with
events/buttons
opening the file, and retrieve the parameter, then fire the query after
validating the parameter.
Anyway, here's a little attempt showing a very smallish routine - of
course there's no errorhandling, no testing whether the file actually
exists ... and probably a bit of other testing/tweaking would be
needed.
Public Function GetMyParameter() As String
Dim intFile As Integer
Dim strParameter As String
Const cstrFileName As String = "c:\test.txt"
intFile = FreeFile
Open cstrFileName For Input As #intFile
If Not EOF(intFile) Then
Input #intFile, strParameter
End If
Close #intFile
GetMyParameter = strParameter
End Function