Hi and thanks for your help in advance.
an example of my table as below:
WEN Name Gender
123 ABC M
354 ZYW M
8601 cwm F
1183 SAM F
1523 DEN Unknown
What I like to do is create either a form or a query to show record 123,
8601, 1523. Ultimately, if I can create a form, enter the multiple number,
click ok and it will extract those records for me.
I hope what I've asked make sense....PLEASE HELP.
You will need one form with record source written in SQL, like this:
SELECT * FROM myTable
Then create another form and put existing form as subform.
You also need one text box to enter search criteria. When you have
this form created you need to code AfterUpdate event of Text Box. For
simple filter you can code AfterUpdate event like this:
dim strWhere As String
strWhere = strWhere & " [myTableFieldName] LIKE ' " & myFormFieldName
& "'"
or, when filtering numbers:
strWhere = strWhere & " [myTableFieldName] = " & myFormFieldName
To have it filtered by multiply entries delimited with comma, code
needs to loop through string and it needs to repeat above command like
this:
strWhere = strWhere & " [myTableFieldName] LIKE ' " & myFormFieldName
& "' OR "
If Right(strWhere, 4) = " OR " Then
strWhere = Left(strWhere, Len(strWhere)-3)
End If
mySubformName.RecordSource = mySubformName.RecordSource & strWhere
mySubformName.Requery
Basically you need to find the position of comma (,) with InStr
command and remember position of last found comma and simply loop
through string until there are no more commas, i.e.
instr(1, "text, text2", ",")
will return 5.
Let me know if you have trouble with code so I will wrote it for you.
Regards,
Branislav Mihaljev
Microsoft Access MVP