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

ADO syntax question 2

Status
Not open for further replies.

DK47

Programmer
Jun 3, 2003
118
0
0
US
OK So no one that visits this site is up on MSChart.
So be it.

Here's a little trouble syntax problem I have with data access. Any help on this will be appreciated.

This ado call procedure is supposed to return records from the Holdings table if the accounts fields match the LIKE expressions, if the account has a current value and the returned records should be based on the Investor_Number.

The call works fine with the current value and the LIKE expression but for some reason it ignors the Investor_Number filter. I have verified that the frmStartPage.txtInvestorNumber is loaded with the correct Investor number. The textbox and data field are Integers.




adoAddCash.RecordSource = "SELECT * FROM Holdings WHERE (Description) LIKE '%MONEY%' OR (Description) LIKE '%Treasury%' OR (Description) LIKE '%Cash%' AND Current_Value > 0 AND (Investor_Number) = " & frmStartPage.txtInvestorNumber
adoAddCash.Refresh



Thanks in advance,
Dwight

PS Igot a new computer and even though I reinstalled my old xp pro, for some reason I can now issue Helpful Stars
DK
 
Think you just need some parentheses to get this working right:
Code:
adoAddCash.RecordSource = "SELECT * FROM Holdings WHERE  ((Description) LIKE  '%MONEY%' OR (Description) LIKE '%Treasury%' OR (Description) LIKE '%Cash%') AND Current_Value > 0 AND  (Investor_Number) =  " & frmStartPage.txtInvestorNumber
-dave
 
Just add parentheses or when the first 'OR' becomes true the whole statement is true.

adoAddCash.RecordSource = "SELECT * FROM Holdings
WHERE ((Description) LIKE '%MONEY%' OR (Description) LIKE '%Treasury%' OR (Description) LIKE '%Cash%') AND Current_Value > 0 AND (Investor_Number) = " & frmStartPage.txtInvestorNumber
 
Thanks to both of you.
I just told my wife about how long I jerked that string arround and now that I have the answer, it cetainly makes sense and seems so easy.
The wonder is..... When will I start figuring these things out on my own??? Soon I hope.
Many thanks.
Dwight
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top