View Full Version : Searching Ranges


Gary Luca
09-03-2004, 07:47 AM
Hello all,

I need to create a criteria in the search box part of the page that allows the user to enter a range of numbers to search (i.e. find all records dated from one date to another date, or find all houses from this number to that number on a specified street). I can't figure out how to do this. Any ideas?


Cheryl Lemire
09-04-2004, 07:14 AM
Hi Gary,

I am going to assume that you are using a component. There have been a few threads here showing where and how to modify the xbasic for a component. You would need to create a prompt for user dialog which you can copy the code from action scripting. I would suggest finding the threads that show where to modify the xbasic, create a button on a blank form using your table and selecting the appropriate action scripting you need to accomplish your task, then view the xbasic for that script and paste it into your component code modification.

This should at least get you started.

Good luck

Edward Larrabee
09-07-2004, 06:24 AM
The ability to search with a range of values is enabled when you select Allow Search by Form Syntax on the Search Properties page of the Grid Component Builder. See attached picture.

Gary Luca
09-07-2004, 03:23 PM
I have no idea what code to put where or how to edit the xbasic in the web component. Anyone?

Gary Luca
09-07-2004, 03:24 PM
I have that enabled. Now what?

Kevin Anderson
09-07-2004, 04:43 PM
I have not confirmed this in the WAS... but if it works like previous versions of Alpha's QBF you would search a date range using this format in a date field.


enter the first date, two periods, then next date in the range
Alpha knows how to parse it.


Gary Luca
09-08-2004, 05:31 AM
Thanks. I had already tried this. It didn't work.

Gary Luca
09-08-2004, 06:19 AM
Nevermind. Must have had something setup wrong. This syntax does work in WAS. However this isn't a solution for me. It needs to be VERY easy for the user. There should be two boxes (From Date and To Date) used to search the range. Anyone have any idea how to do this?

Cheryl Lemire
09-08-2004, 06:55 AM
Hi Gary,

You can take the code I have at the end of this post and modify it to fit your needs. Mine is used to print invoices based on a beginning and ending date. It prompts the user at runtime for the two dates and then filters the table to return the invoices between the two dates selected by the user.

Good luck

'Date Created: 04-Aug-2004 08:28:23 PM
'Last Updated: 11-Aug-2004 04:18:38 PM
'Created By : Cheryl Lemire
'Updated By : Cheryl Lemire

'Maximize in current form.

'prompt for beginning and ending dates
filter = " (Inv_date "= [varD-"prms.Parameter1] ) .AND. (Inv_date "= [varD-"prms.Parameter2] )"
get_parameters_string = ""%string%
Parameter1|Beginning date|Date|calendar||

Parameter2|Ending date|Date|calendar||
ok_label = "&OK"
cancel_label = "&Cancel"
dialog_title = "Parameters"

'Prompt for parameter values. Store results in a 'dot' variable called 'prms'
dim prms as p
prms = ui_get_parameters(dialog_title,get_parameters_string,ok_label,cancel_label)

if prms.last_button_pressed = "OK" then
'Replace parameters in the filter with actual values
query.filter = replace_parameters(filter,local_variables())

query.order = ""
end if

'Prompt user whether to print, or preview the layout. Set default to Print
prompt_result = ui_get_print_or_preview("Print")
If prompt_result = "Print" then


Else if prompt_result = "Preview" then
End if

Selwyn Rabins
09-09-2004, 01:37 PM
am not clear why you say that entering date search criteria like this:


does not work?

as far as i can tell, it works fine.

for example, using the sample demo web pages that ship with a5.

at the main menu, if you click on "InvoiceHead Grid - Tabular layout based on a view"

you will get a grid that has a date field in the search part.

in the date field enter:


and then click search.

a5 finds two records.

you can even combine ranges

7/1/02..7/31/02, 1/1/02..1/10/02

Gary Luca
09-10-2004, 05:17 AM
It didn't work at first. I think I may have screwed something up in my component. But I went and recreated the whole page and then it worked. I posted a "nevermind" to my comment about it not working after I got it to work. See above.

Selwyn Rabins
09-10-2004, 06:04 AM
if you need to create your own custom search then you can do this quite easily by combining a Dialog component and a Grid component.

you would create a Dialog component that had to data fields on it. statDate and endDate

in the AfterValidate event on the Dialog component you would construct the URL to open the page the that had the Grid component on it and you would set the currentPage.redirectTarget (i forget the exact name of the property) to the URL that you computed.

there is an example in the sample web app demo that ships with a5. see the example of cascading lookups in a dialog box. while your situation does not use cascading lookups, the final step is the same -- when you click the submit button, you open a page that has a Grid on it.