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!

Change Query in SQL

Status
Not open for further replies.

Bubsi

Technical User
Aug 27, 2002
21
DE
I use the following code in a push-button method in a form.
Now I want to use sql-commands but I don't know how to use the "qBill" variable in the sql commands.
I have also problems to change the "if not qvar.executeQBE". Is there an equal command for sql ?

The actual syntax is:
var
qVar Query
r report
qBill string
endvar

if billNo.value = ""
then qBill = "" ;get all bills
else qBill = ", "+billNo.value ;only the bill you want
endif

qvar = Query
Account.DB | Number | Date | Client |
| Check ~qBill | Check | Check |
EndQuery

if not qvar.executeQBE(":priv:answer.db")
then errorShow()
endif

 
Hi Bubsi

If I ain't wrong, this should do it.

var
qVar Query
db Database
mySQL SQL
r report
qBill string
endvar

if billNo.value = ""
then qBill = "''" ;get all bills
else qBill = "'" +billNo.value + "'" ;only the bill you want
endif


db.open(":WORK:")
mySQL = SQL

SELECT Number, Date, Client
FROM Account
WHERE Number = ~qBill
ORDER BY Number, Date, Client

endSQL

if not mySQL.executeSQL(db,":priv:answer.db") then
errorShow("executeSQL failed")
endIf
 
Hi carstenFH,

thanks for your help but it doesn't work.
Perhaps the ~qBill will be the problem.
May I send you the complete commands?
 
Yes - that's all right with me.

You could also try copy/paste this, and see if it takes any effect.

if billNo.value = ""
then qBill = "''" ;or change it to: qBill = ""
else qBill = "'," +billNo.value + "'" ;or change it to: qBill = "," +billNo.value
endif

There was a comma in qBill, which I belived did no good, so I removed it - might make the difference.
The code I posted earlier worked in the setup I made to test it.

else cfh@post5.tele.dk

Carsten
 
Hi Carsten,

thanks a lot.

With the following code it worked without any problems.

if billNo.value = ""
then qBill = "''" ;get all bills
else qBill = "'"+billNo.value+"'" ;only the bill you want
endif
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top