Multifield Search, Incorporating age range criteria?

106 views Asked by At

I'm trying to add a multifield search into a form, but I ran into a jam. I have it figured out for my 4 text fields. Here's the code I use utilizing wildcards so that it searches all records if it's left blank

Like "*" & [Forms]![Patient Tracking]![FNSearch] & "*"

But now, I'm trying to add an age range feature. It's stored as a simple numerical field. I just need to create a way where you can enter an age range (lowest in textbox named minage, highest in maxage textbox) and have it also be ignored if left blank.

Any idea how to create this criteria?

this is the entire code of the query in sql:

    SELECT [Patient Tracking].[First Name], [Patient Tracking].[Last Name], [Patient Tracking].City, [Patient Tracking].Sex, [Patient Tracking].Age
FROM [Patient Tracking]
WHERE ((([Patient Tracking].[First Name]) Like "*" & Forms![Patient Tracking]!FNSearch & "*") And (([Patient Tracking].[Last Name]) Like "*" & Forms![Patient Tracking]!lnsearch & "*") And (([Patient Tracking].City) Like "*" & Forms![Patient Tracking]!citysearch & "*") And (([Patient Tracking].Sex) Like "*" & Forms![Patient Tracking]!sexsearch & "*"))
1

There are 1 answers

0
user2744572 On

I found a simpler method using the NZ Function,

Between Nz([Forms]![Patient Tracking]![minage],0) And Nz([Forms]![Patient Tracking]![maxage],10000) Or Is Null

thanks for the help