469,926 Members | 1,489 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,926 developers. It's quick & easy.

How do multiple select statements

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

I have this
Expand|Select|Wrap|Line Numbers
  1.  objCommand.CommandText = "Select * from table"
  2.     objCommand.CommandText1 = "Select * from table where number like" & Val(txtSearchList.Text)
  3.     objCommand.CommandTimeout = 30
  4.     objCommand.CommandType = adCmdText
  5.     Set objRS = objCommand.Execute
  6.     Set objCommand = Nothing
  7.     Do Until objRS.EOF
  8.            Reference(Number) = objRS("Number")
  9.         Number = Number + 1
  10.         objRS.MoveNext
  11.     Loop
  12.     objRS.Close
  13.     Set objCommand = Nothing
  14.     Set objRS = Nothing
  15.     Number = Number - 1
  16.     For display = 0 To Number
  17.            lstVoucherAmt.AddItem Reference(display)
  18.     Next
  19.  
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?
Mar 5 '08 #1
7 1965
Killer42
8,435 Expert 8TB
... 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?
Mar 6 '08 #2
QVeen72
1,445 Expert 1GB
Hi,

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

Regards
Veena
Mar 6 '08 #3
Killer42
8,435 Expert 8TB
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.
Mar 6 '08 #4
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?
Mar 7 '08 #5
debasisdas
8,127 Expert 4TB
Try using

objCommand.CommandText = "Select * from table where number =" & Val(txtSearchList.Text)

No need of this at all
objCommand.CommandText1 =.........

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.
Mar 7 '08 #6
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.
Mar 7 '08 #7
debasisdas
8,127 Expert 4TB
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.
Mar 7 '08 #8

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

8 posts views Thread by MrTrix | last post: by
4 posts views Thread by ctoth | last post: by
2 posts views Thread by Annie D via AccessMonster.com | last post: by
3 posts views Thread by Joe via DotNetMonster.com | last post: by
1 post views Thread by microsoft.public.dotnet.languages.vb | last post: by
2 posts views Thread by =?Utf-8?B?VGVycnk=?= | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.