Connecting Tech Pros Worldwide Forums | Help | Site Map

VB6 Reading Mdb query specific item

Member
 
Join Date: Jul 2007
Posts: 104
#1: Jun 11 '09
Hi all, I have a mdb with a query called ReportQ, it has 2 columns namely Tel2 and Sum Of knowledge and the querry looks like this:

Tel2 ...... Sum of Knowledge
1................. 100
2................. 325
3 ................. 243
etc.

Please could someone check my code to see where i have gone wrong as my result gives "false" as the answer.

All I want is to lookup in the query (ReportQ in mdb)
where Tel2 = 1 to give me the result of 100
or Tel2 = 2 to give me 325
etc.

VB6 Code :
mthrep.TextArray(8) = Adodc1.RecordSource = "Select * From ReportQ Where Sum Of Knowledge LIKE Tel2 = 1"

Thanks so much
Werner

Expert
 
Join Date: Jun 2007
Location: Derbyshire, UK
Posts: 369
#2: Jun 11 '09

re: VB6 Reading Mdb query specific item


Quote:

Originally Posted by Wernerh View Post

Hi all, I have a mdb with a query called ReportQ, it has 2 columns namely Tel2 and Sum Of knowledge and the querry looks like this:

Tel2 ...... Sum of Knowledge
1................. 100
2................. 325
3 ................. 243
etc.

Please could someone check my code to see where i have gone wrong as my result gives "false" as the answer.

All I want is to lookup in the query (ReportQ in mdb)
where Tel2 = 1 to give me the result of 100
or Tel2 = 2 to give me 325
etc.

VB6 Code :
mthrep.TextArray(8) = Adodc1.RecordSource = "Select * From ReportQ Where Sum Of Knowledge LIKE Tel2 = 1"

Thanks so much
Werner

Hi

"Select [Sum Of Knowledge] From ReportQ Where Tel2 = 1"

Is that what you mean?

(assuming Tel2 is numeric?)

MTB
Member
 
Join Date: Jul 2007
Posts: 104
#3: Jun 11 '09

re: VB6 Reading Mdb query specific item


Hi MTB,

Yes both fields are numeric. Tel 2 is essentially a lookup code and Sum of ..... is the result of a few tables against that code. So I have code 1-62 under Tel2 and the totals from the tables relevant to the individual codes as a single entry in this query. Does that make sense?

Thanks
Werner
Member
 
Join Date: Jul 2007
Posts: 104
#4: Jun 11 '09

re: VB6 Reading Mdb query specific item


I have placed the brackets as you have indicated and still getting "False" as result in my datagrid
daniel aristidou's Avatar
Needs Regular Fix
 
Join Date: Aug 2007
Posts: 493
#5: Jun 11 '09

re: VB6 Reading Mdb query specific item


um i just got a question why are you looking up in another query, is it not possible to create a single query rather than multiple queries,
Quote:
Select * From ReportQ Where [Sum Of Knowledge] LIKE Tel2 = 1"
Which you are at the moment.
And secondly im no expert in sql but from what i know it seems u have 2 conditions. you are asking it to tell you if the [Sum of knowledge] is like TEl2 .... When Tel2 is equal to 1- If that is what you intend to achieve why not simply use:

Expand|Select|Wrap|Line Numbers
  1. Select * From ReportQ Where [Sum Of Knowledge] LIKE 1"
.

Hope that might help
Reply