View Full Version : Dialog Filter help


06-23-2008, 02:08 PM
I have tried looking through the various help guides and I know this is a simple problem to solve, but . . . it is driving me crazy.

I have a dialog that is printing out a report which works fine. I now want to add in the dialog a user field (Hosp) to be a pretty simple filter that will limit the report based on the value the user types into this dialog's field.

So the filter fires on the FormEvent AfterValidate as part of the dialog component:

dim filter as C
filter = (Hosp = patient->hospital)

(I am showing what I am trying to accomplish - I know this is not even close on properly phrasing this filter.)

"Hosp" is the dialog component and "patient->hospital" is the field in the table "patient" that I want to match up.

So how do I phrase this? I know this is simple but I am missing it.


Mike Scholin

06-23-2008, 09:06 PM
I figured it out!

filter = ("Hospital=\""+hosp+"\"")

I have no idea as to why this works but it does.

NOW, the other part of the filter that worked great by itself won't work together with the above using an ".and." join.

filter = "patient->date_of_service >= " + s_quote(ctod(from_date)) + " .and. patient->date_of_service <= " + s_quote(ctod(to_date)).and.("Hospital=\""+hosp+"\"")

When this runs together I get:
Errors in: event.AfterValidate code:
Argument is incorrect data type

What needs to be changed to make them run together?


Pat Bremkamp
06-23-2008, 09:49 PM
You need to include the final .and. in the final set of quotes with Hospital.

Steve Wood
06-24-2008, 03:56 AM
Compound filters are a pain. One helpful hint is to place save_to_file("c:\test.txt",filter) somewhere after you set the filter value and to comment out the code that causes the page to fail, so it won't fail.

That way you will get your resolved filter expression written to test.txt and can view it for syntax errors.

06-24-2008, 07:45 AM
Pat, I have tried several different configurations/combinations of quotes and slashes but with no success.

Were you able to see specifically where I needed the quotes?

As Steve confirmed (glad it just wasn't me only), these compound filters are a pain!

Thanks, Mike

Steve Wood
06-24-2008, 08:01 AM
Its difficult to parse without your database to bounce against. Maybe this will help, here are several working filter expressions with lots of slashes and .and.'s.

?str(tablecount("[PathAlias.ADB_Path]\tr_trust", "Customer_ID = " + quote(session.customer_id) + " .and. Online_Submit_Status <> .t."))

? str(tablecount("[PathAlias.ADB_Path]\tr_trust", "(Customer_id = \""+session.customer_id + chr(34) + ".OR. Attorney_id = \""+session.customer_id + "\") .and. Received_Date > " + s_quote(date()-60)))

varfilter = "date() - ctod(time(\"MM/dd/yyyy\",Regdate))= " + s_quote(dy) + ".and. regstatus ="+s_quote(rs)

record_delete("datapath\web_users","regstatus = 'pending' .and. date() > regdate + "+expdays)

06-24-2008, 08:27 AM
Thanks Steve! I love good examples - I have figured more things out with sample code than through any other source.

I guess it is not the same but it sure would be nice if you could build these filters like you do in alpha expressions (grids) and then see the translation that would work for xbasic.

Thanks again for your help.

06-24-2008, 02:14 PM
Well, I got it working between Pat's suggestion and Steve's examples AND A whole LOT OF JUST PLUGGING IN A LOT OF QUOTES WITHOUT ANY UNDERSTANDING WHY!!!

filter =" Hospital=\""+hosp+"\"" ".and. ""patient->date_of_service >= " + s_quote(ctod(from_date)) + " .and. patient->date_of_service <= " + s_quote(ctod(to_date))

It all works great now and will be a big boost to my application, but I do wish I could understand why it is working!!
Steve, you are so correct that these compound filters are a pain!

Thank you guys for helping.