How do multiple select statements

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • golffor1
    New Member
    • Mar 2008
    • 4

    How do multiple select statements

    Hello I was wondering if you could help me out with doing multiple select statements.

    I have this
    Code:
     objCommand.CommandText = "Select * from table"
        [B]objCommand.CommandText1 = "Select * from table where number like" & Val(txtSearchList.Text)[/B]
        objCommand.CommandTimeout = 30
        objCommand.CommandType = adCmdText
        Set objRS = objCommand.Execute
        Set objCommand = Nothing
        Do Until objRS.EOF
               Reference(Number) = objRS("Number")
            Number = Number + 1
            objRS.MoveNext
        Loop
        objRS.Close
        Set objCommand = Nothing
        Set objRS = Nothing
        Number = Number - 1
        For display = 0 To Number
               lstVoucherAmt.AddItem Reference(display)
        Next
    The line that is in bold is the one I am having trouble with. THen I want it to put the value it finds from the second select statement, into another box. Do you have any suggestions on how to do this?
  • Killer42
    Recognized Expert Expert
    • Oct 2006
    • 8429

    #2
    Originally posted by golffor1
    ... THen I want it to put the value it finds from the second select statement, into another box. Do you have any suggestions on how to do this?
    I don't get it. Why can't you just perform the same process again for the second query?

    Comment

    • QVeen72
      Recognized Expert Top Contributor
      • Oct 2006
      • 1445

      #3
      Hi,

      What error you are getting...?
      And you have to use "Like" Operator on Strings, not on Numeric Fields..

      Regards
      Veena

      Comment

      • Killer42
        Recognized Expert Expert
        • Oct 2006
        • 8429

        #4
        Good catch, Veena.

        Yes, the Like operator is used to match strings using wildcard characters. It's not applicable to a number. You probably should be using the = operator.

        Comment

        • golffor1
          New Member
          • Mar 2008
          • 4

          #5
          if I use the = I get a n error that states:

          method or data member not found.

          What I want to do is...what the second sql statement finds I want to put in the text a text box. I don't know how easy this is?

          Comment

          • debasisdas
            Recognized Expert Expert
            • Dec 2006
            • 8119

            #6
            Try using

            objCommand.Comm andText = "Select * from table where number =" & Val(txtSearchLi st.Text)

            No need of this at all
            objCommand.Comm andText1 =.........

            Try to change the field name in database. Don't use Number as field name. That might create some problem. As that is a key word.

            Comment

            • golffor1
              New Member
              • Mar 2008
              • 4

              #7
              I think the issue there is I am not able to change the database. So I have to use number, if I change the field then it could mess with the store procs in sql.

              Comment

              • debasisdas
                Recognized Expert Expert
                • Dec 2006
                • 8119

                #8
                Originally posted by golffor1
                I think the issue there is I am not able to change the database. So I have to use number, if I change the field then it could mess with the store procs in sql.
                Then try changing the code as suggested in post #6.

                Comment

                Working...