Dave Edwards
New member
- Local time
- Today, 18:17
- Joined
- Apr 3, 2000
- Messages
- 8
Can anyone help me please.
I have been trying to create a report by using a query to include those records specified by the user. One field of a table can contain a number of letters eg
ABC, ADB, CDEB, or DEA etc. I want the user to be able to enter *their* selection of letters (in any order), and then match *any* of their chosen letters with those held in the field so if they entered AD then in my example above it would match on fields 2 and 3 as they both contain at least one of these letters. I don't believe that it can be done with a normal query string, and so a function has been suggested to me.
This is as far as I have got;
Public Function InChars(ByVal strLookFor As String, ByVal strInField As String) As Boolean
Dim i As Integer
InChars = False
For i = 1 To Len(strLookFor)
If InStr(strInField, Mid(strLookFor, i, 1)) = 1 Then
InChars = True
Exit For
End If
Next
End Function
Where in the field of my query I have the following;
Values: InChars([Enter letters:],[TableField])
This gives the user a parameter box into which they can enter their choice of letters. But the table that is created from this contains ALL records from the original table, and not those that were true -1. Athough the records that should match do contain a -1 whereas non matches contain a 0 or an #Error if the field was empty. What I want is for the table to contain *only* those records where they match ie that are currently marked as -1
I've got this far and am probably missing something obvious - can anyone help please.
Dave
I have been trying to create a report by using a query to include those records specified by the user. One field of a table can contain a number of letters eg
ABC, ADB, CDEB, or DEA etc. I want the user to be able to enter *their* selection of letters (in any order), and then match *any* of their chosen letters with those held in the field so if they entered AD then in my example above it would match on fields 2 and 3 as they both contain at least one of these letters. I don't believe that it can be done with a normal query string, and so a function has been suggested to me.
This is as far as I have got;
Public Function InChars(ByVal strLookFor As String, ByVal strInField As String) As Boolean
Dim i As Integer
InChars = False
For i = 1 To Len(strLookFor)
If InStr(strInField, Mid(strLookFor, i, 1)) = 1 Then
InChars = True
Exit For
End If
Next
End Function
Where in the field of my query I have the following;
Values: InChars([Enter letters:],[TableField])
This gives the user a parameter box into which they can enter their choice of letters. But the table that is created from this contains ALL records from the original table, and not those that were true -1. Athough the records that should match do contain a -1 whereas non matches contain a 0 or an #Error if the field was empty. What I want is for the table to contain *only* those records where they match ie that are currently marked as -1
I've got this far and am probably missing something obvious - can anyone help please.
Dave