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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Query Criteria

Status
Not open for further replies.

richmiester

IS-IT--Management
Nov 13, 2002
4
US
New to the forum, looks great!

I've used Pdox for about 6 years now, begining in the old Pdox for DOS days. I've never really done more than some complex queries (always using the GUI) and create/manipulate tables, etc - no scripts or code.

Something I've always wondered about, is there a way to ask the user for criteria and insert it into a query you write. I assume you would write the query with a variable listed as criteria i.e. Date field = var_date - or something to that effect. But how do you actually ask the end user to supply that info?

Thanks!
 
richmiester,

You've got a few different ways you can do this. but, there are two basic tachniques. You can:

1. Prompt the user for the value:

Code:
var
   liCustNo  LongInt
endVar

   liCustNo = -1
   liCustNo.view( "Enter Customer ID" )
   if licustNo = -1 then
      formReturn( FALSE )
   endIf

(Note: I personally don't like this approach for there's no way to tell if the user cancels the prompt)

2. Place an unbound field object on the form:

Code:
var
   liCustNo  LongInt
endVar

   liCustNo = myInputFieldObj.Value

There are variations on this, including creating a separate form to prompt the user from dialog box that handles additional eror checking, but that's basically the same as #2.

Hope this helps...

-- Lance
 
You can use a form. The code below is from a practice form I made. The form has a list of employees and a button. User selects a name from the list and pushes the button. The push-button code runs a query that finds that employee's open projects.

Code:
method pushButton(var eventInfo Event)

var
  q      query
  tv     tableview
  qName  string
endVar

doDefault

;Turn selected name into query variable
qName = nameList.value

q=Query ;Tilde indicates query variable

assigned.DB | Assigned       |
            | ~qName, _join1 |


projects.db | Year  | ProjNumber | Assigned     |
            | Check | Check      | Check _join1 |

EndQuery

if not executeQBE(q) then

errorShow()
setMouseShape( mouseArrow )
   errorShow( "Error","Can't run query")
   q.writeQBE( ":PRIV:BADQUERY.QBE" )

else

tv.open("answer.db")

endIf

endMethod
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top