20 Apr 12 15:36
You cannot simply write VB code on the fly and use it. What you are trying to do will not work because the statement Case strSelectString does not compare strRecordType with all string matches, but with one string only which literally looks like this: "String1", "String2", "String3", "String4", "String5"
Try the following code which reads the file contents into an array and uses Filter function to see if a match is found.
Dim tsControlFile As TextStream
Dim arrMatches() As String
Set tsControlFile = fso.OpenTextFile(App.Path & "\ControlFile.txt", ForReading)
arrMatches = Split(tsControlFile.ReadAll, vbNewLine)
If UBound(Filter(arrMatches, """" & strRecordType & """", , vbTextCompare)) >= 0 Then
Here, contents of whole file are read at once with ReadAll method and parsed into an array (arrMatches) using the Split function. The Filter function searches this array for a match. If a match is found, it returns an array which has at least one element and UBound function returns a 0 or higher value. If no match is found, UBound returns -1, indicating an empty array with no match.
Note that this code assumes that you are using quotes around each match in the text file, as you stated above. If you remove those quotes, this code will not work.