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!

How do I allow the user to make an input during a query?

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
I would like to allow the user to input a start and stop date during a query. I am using Paradox 8 for Windows.
 
I would build a form with 2 unbounded fields to accept start and end dates.

Here is a quick and dirty way that you can do from a scrip:

Var
Q Query
sStartDate String
dStartDate Date
lError Logical
dEndDate Date
sEndDate String
EndVar

;Get start date
sStartDate = ""
sStartDate.View("enter a day")

;Verify if user entered a value
If sStartDate = "" Then
MsgStop("Error","No date is entered.")
Return
EndIf

;Verify the entered value is a valid date.
lError = False
Try
dStartDate = DateVal(sStartDate)
OnFail
lError = True
EndTry

If lError Then
MsgStop("Error",sStartDate+". Invalid date.")
Return
EndIf

sStartDate = Format("DM2,DD2,DY3",dStartDate)


;Copy the above codes and change startdate to Enddate
;


;Query
Q=Query

table.db | Start Date | End Date |
Check | >=~sStartDate | <=~sEndDate |
EndQuery
If Not Q.ExecuteQBE() Then
MsgStop(&quot;Error&quot;,&quot;Cannot execute query.&quot;)
Return
EndIf
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top