VB6 Reading Mdb query specific item

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Wernerh
    New Member
    • Jul 2007
    • 104

    VB6 Reading Mdb query specific item

    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.TextArra y(8) = Adodc1.RecordSo urce = "Select * From ReportQ Where Sum Of Knowledge LIKE Tel2 = 1"

    Thanks so much
    Werner
  • MikeTheBike
    Recognized Expert Contributor
    • Jun 2007
    • 640

    #2
    Originally posted by Wernerh
    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.TextArra y(8) = Adodc1.RecordSo urce = "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

    Comment

    • Wernerh
      New Member
      • Jul 2007
      • 104

      #3
      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

      Comment

      • Wernerh
        New Member
        • Jul 2007
        • 104

        #4
        I have placed the brackets as you have indicated and still getting "False" as result in my datagrid

        Comment

        • daniel aristidou
          Contributor
          • Aug 2007
          • 494

          #5
          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,
          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:

          Code:
          Select * From ReportQ Where [Sum Of Knowledge] LIKE 1"
          .

          Hope that might help

          Comment

          Working...