Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Searching by a range of dates 1

Status
Not open for further replies.

woodyinoz

IS-IT--Management
Jan 8, 2002
215
GB
I have a field full of dates and from time to time it is required that informtaion is displayed for a certain time period i.e. 30/01/02 to 19/02/02.
This range is required to be entered by the user through some dialog box, or something similar.

Can anyone help on this one?

Thanks,

Woody
 
I suppose you have a form where data is displayed in a table frame or as individual fields.
For performance considerations, you should first have an index where the date is the first field. Other fields can be in the index.
Then, to retrieve min max dates from the user, a quick and dirty way is to have 2 date variables and use the view () function :
minDate.view ()
maxDate.view ()
The user is presented a box with the current value, and can alter it. Since its a date variable, a validity check is performed.
Or you can have 2 undefined fields in the form, along with a button the user must press after filling the fields. You have then to ensure date validity by code.
When you have the dates, its quite straightforward. Lets say myUiObject is a (UI) field of your table, a tableFrame or object containing them (only if your table is the primary table in the form's data model). Use the code

myUiObject.switchIndex ("iDate", true)

in the case the form wasnt already using your index ; iDate is the name of the index used with the date as first field ; true is optional and tells the form to stay on the current record if possible.

myUiObject.setRange (minDate, maxDate)

to limit the view to the range you want.
then you can use

myUiObject.setRange ()

to reset the view to all records.

Hope this aint too confusing.
 
Woody,

On a form you could have two user input fields called UIFrom and UITo (or any names you so wish). Then attach code similar to that below to a button. That should at least help you capture all of the data between the from and to values.


Var
STildeFrom, STildeTo String
Qry1 Query
tv TableView
EndVar

sTilde1 = UIFrom.value
sTilde2 = UITo.Value

Qry1 = query
Answer: :priv:__Results.Db

:Work:YourTable.DB |Ref |Dates |
|Check|Check <=~sTilde2, >=~sTilde1|
EndQuery

executeQBE(Qry1)

tv.Open(&quot;:priv:__Results.db&quot;)



Regards

Bystander

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top