This topic is locked

Advanced Search Default Values to Look for

10/19/2005 03:34:42
ASPRunnerPro General questions
author

Hi is it posible to set default values to a date field in advanced search with "between" condition so we can show only records updated within the last two days? Then allow the user to change the values to search for?
Would be interensting if ASPRunner can set defauld values to search or advanced search. Exelent Product!!!
Thanks <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=question&id=2000&image=1&table=forumtopics' class='bbc_emoticon' alt=':D' />

Sergey Kornilov admin 10/19/2005

You can do this by adding the following three lines in the beginning of list page (see in bold)

Session("SearchOption_" & strTableName & "DateField") = "Between"

Session("SearchFor1" & strTableName & "DateField") = FormatDatetime(DateAdd("d", -2, now()),2)

Session("SearchFor2
" & strTableName & "_DateField") = FormatDatetime(now(), 2)

Session.LCID = 1033


Make sure you replace DateField with actual field name.

500350 11/17/2005

Sergey, thanks for the help.
It actually set the values to the advanced search correctly but it shows all the records anyways. Unless I go to advanced search and click the search button.
How can I show, the first time they see the page, only the records that match the selection and not all of them? THX.

Sergey Kornilov admin 11/17/2005

To point your users directly to advanced search results you can do the following:
To dipslay parameters open ..._search.asp in text editor and change FORM tag to use GET instead of POST. Do required search and copy URL. Change form back to POST. Use this URL to setup direct link to advanced search results - that would be the first page your users see.

500351 11/17/2005

Thanks Sergey: It work fine, but, there seems to be a problem; We select last 2 days of data (todays date -2) so tomorrow or next week is going to show the data as of today.
In other words, It seems to me that is not going to be dynamic. that any time showl select last two days data for default and if they want to change it they go to advaced search.
Thanks

500352 11/18/2005

May be forcing the action here.
if Request("action")<>"Search" and Request("action")<>"AdvancedSearch" and Len(Session(strTableName & "SQL"))>3 then

.........

.............

...............

.................

if Request("action")="AdvancedSearch" then
Would make sence, just the first time, changing the values for Request("action") to contain "AdvancedSearch" and if it does how, I have tried so many things but can not get it?

Is there any other way uff!!!! I'm confused.

Thanks

R
rodriguez 12/1/2005

Hi Sergey, could you please help us with this?

Thank you!

Sergey Kornilov admin 12/1/2005

I'm kind of confused with what you trying to achieve.
Please clarify.

R
rodriguez 12/1/2005

What I need to do is to display the page with the data already selected, with the dates between last 2 days

that I have put as parameters in the advancedsearch.

As I explained before, I cannot copy the URL as you suggested because this is not a fixed parameter but a variable one considering today date - 2.

We really need to show the data of the last 2 days the first time they see the page and at the same time allow them to change the parameter in the advancedsearch to see all the data or any range of days data.

Thanks!

Sergey Kornilov admin 12/1/2005

I see what you saying.
I would recommend to use No records on the first page option and modify generated ..._list.asp file after that.
Replace the following line:

strSQL = AddWhere(strSQL, "1=0")


with something like this:

strSQL = AddWhere(strSQL, "DateDiff("d", DateField, now())<2 and ... ")