Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsVB SyntaxEnterprise DevelopmentDatabase AccessControlsCOMWin APICrystal ReportDeploymentGeneralGeneral 2
Related Topics
VB.NET / ASP.NETMS SQL ServerMS AccessOther Database ProductsMore Topics ...

VB Forum / Database Access / December 2004



Tip: Looking for answers? Try searching our database.

how to capture the text in a textbox into a sql select statement?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Kate - 30 Dec 2004 02:29 GMT
say, I have 2 textboxes (txt1, txt2) in form1.  when the user enters a value
in txt1 and click the command button, a value should be returned to txt2.

Here's what I put in the procedure:
Set sdoRs = sdoConn.Execute("select mslink as msl from slope where slope_num
= form1.txt1.text")

in the form:
txt2.text = sdoRs("msl")

but I don't think it understands form1.txt1.text.  If I hard code a value,
it works.
What should I put instead of form1.txt.text?

Thanks,
Kate
Veign - 30 Dec 2004 03:40 GMT
Because it works with a hard coated value Im assuming the Connection and
Recordset are properly setup so all you would have to do is change it to:
Set sdoRs = sdoConn.Execute("SELECT mslink AS msl FROM slope WHERE slope_num
= '" & form1.txt1.text & "'")

Signature

Chris Hanscom - Microsoft MVP (VB)
Veign's Resource Center
http://www.veign.com/vrc_main.asp
--

> say, I have 2 textboxes (txt1, txt2) in form1.  when the user enters a value
> in txt1 and click the command button, a value should be returned to txt2.
[quoted text clipped - 12 lines]
> Thanks,
> Kate
Kate - 30 Dec 2004 07:45 GMT
Thanks Veign,

I just tried to use:
Set sdoRs = sdoConn.Execute("select mslink as msl from slope where slope_num
= ' " & form1.txt1.text & " ' ")
but I still got run-time error: 3021, when I tried to type in txt1.

Rebecca

> Because it works with a hard coated value Im assuming the Connection and
> Recordset are properly setup so all you would have to do is change it to:
[quoted text clipped - 19 lines]
> > Thanks,
> > Kate
Veign - 30 Dec 2004 15:26 GMT
If you replace the form1.txt1.text with an actual value all works?  What is
the value you are entering - is it numeric?

If it is a numeric value then remove the single quotes from each side of
form1.txt1.text and it should work.

Signature

Chris Hanscom - Microsoft MVP (VB)
Veign's Resource Center
http://www.veign.com/vrc_main.asp
--

> Thanks Veign,
>
[quoted text clipped - 28 lines]
> > > Thanks,
> > > Kate
Kate - 30 Dec 2004 15:51 GMT
I put string...

> If you replace the form1.txt1.text with an actual value all works?  What is
> the value you are entering - is it numeric?
[quoted text clipped - 39 lines]
> > > > Thanks,
> > > > Kate
Veign - 30 Dec 2004 15:51 GMT
Gonna have to give more information than that.

> > If you replace the form1.txt1.text with an actual value all works?

Signature

Chris Hanscom - Microsoft MVP (VB)
Veign's Resource Center
http://www.veign.com/vrc_main.asp
--

> I put string...
>
[quoted text clipped - 41 lines]
> > > > > Thanks,
> > > > > Kate
Kate - 31 Dec 2004 02:15 GMT
sorry veign :p
ok, here's what I put:

doesn't work-
Set sdoRs = sdoConn.Execute("select mslink as msl from slope where slope_num
= '" & form1.txt1.text & "'")

works-
Set sdoRs = sdoConn.Execute("select mslink as msl from slope where
slope_num = '2sw-a/c134'")

the value of msl of '2sw-a/c134' should be displayed in txt2, if I enter
2sw-a/c134 in txt1 (using the 'doesn't work' code).  But when I tried to
enter value in txt1, I got the run-time error 3021.  And of course, when I
use the 'works' code, I can enter any value in txt1, and still get the msl of
2sw-a/c134 in txt2.

thanks much!
kate

> Gonna have to give more information than that.
>
[quoted text clipped - 51 lines]
> > > > > > Thanks,
> > > > > > Kate
Kate - 31 Dec 2004 02:17 GMT
sorry veign :p
here's what I put:

doesn't work-
Set sdoRs = sdoConn.Execute("select mslink as msl from slope where slope_num
= '" & form1.txt1.text & "'")

works-
Set sdoRs = sdoConn.Execute("select mslink as msl from slope where slope_num
= '2sw-a/c134'")

the value of msl of 2sw-a/c134 should be displayed in txt2, if I enter
'2sw-a/c134' in txt1 (using the 'doesn't work' code).  but when I tried to
enter value in txt1, I got the run-time error 3021.  and of course, when I
used the 'work' code, I can enter any value in txt1, and still got the msl of
2sw-a/c134 in txt2.

thanks much!
kate

> Gonna have to give more information than that.
>
[quoted text clipped - 51 lines]
> > > > > > Thanks,
> > > > > > Kate
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.