Display in a text box a query 
Author Message
 Display in a text box a query

Hi,
I'm trying to display in a textbox a result of a query using ADO
connection to a database
I'm not sure if the code is right...

Private Sub Cmd_Click()
Set Cn = New ADODB.Connection
Cn.ConnectionString = "provider=Microsoft.jet.oledb.4.0;Data Source="
& App.Path & "\gestmail.mdb"
Cn.Open
Set Rs3 = New ADODB.Recordset
Rs3.CursorLocation = adUseClient
Rs3.Open "SELECT reference FROM [principal] WHERE data =" &
Combo1.Text, Cn, adOpenfowardonly
Txt1.Text = reference
End Sub

Does anyone know?
Thanks!

      Pucca



Fri, 30 Sep 2005 03:23:35 GMT  
 Display in a text box a query
Txt1.Text=Rs3.Fields("Reference").Value

If there are more than one row fetched then set the multiline property of
the text box to true, loop through the recordset
and

txt1.Text=Rs3.Fields("Reference").Value & vbcrlf

--
Regards

Sukesh Hoogan

http://personal.vsnl.com/sukesh_hoogan


Quote:
> Hi,
> I'm trying to display in a textbox a result of a query using ADO
> connection to a database
> I'm not sure if the code is right...

> Private Sub Cmd_Click()
> Set Cn = New ADODB.Connection
> Cn.ConnectionString = "provider=Microsoft.jet.oledb.4.0;Data Source="
> & App.Path & "\gestmail.mdb"
> Cn.Open
> Set Rs3 = New ADODB.Recordset
> Rs3.CursorLocation = adUseClient
> Rs3.Open "SELECT reference FROM [principal] WHERE data =" &
> Combo1.Text, Cn, adOpenfowardonly
> Txt1.Text = reference
> End Sub

> Does anyone know?
> Thanks!

>       Pucca

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.471 / Virus Database: 269 - Release Date: 10/04/2003


Fri, 30 Sep 2005 09:22:54 GMT  
 Display in a text box a query
Rs3.Open "SELECT reference FROM [principal] WHERE data ='" & Combo1.Text &
"'", Cn, adOpenfowardonly

Enclose Combo1.Text within single quotes, if the value in it is not numeric.
--
Regards

Sukesh Hoogan

http://personal.vsnl.com/sukesh_hoogan


Quote:
> Hi,
> I'm trying to display in a textbox a result of a query using ADO
> connection to a database
> I'm not sure if the code is right...

> Private Sub Cmd_Click()
> Set Cn = New ADODB.Connection
> Cn.ConnectionString = "provider=Microsoft.jet.oledb.4.0;Data Source="
> & App.Path & "\gestmail.mdb"
> Cn.Open
> Set Rs3 = New ADODB.Recordset
> Rs3.CursorLocation = adUseClient
> Rs3.Open "SELECT reference FROM [principal] WHERE data =" &
> Combo1.Text, Cn, adOpenfowardonly
> Txt1.Text = reference
> End Sub

> Does anyone know?
> Thanks!

>       Pucca

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.471 / Virus Database: 269 - Release Date: 10/04/2003


Fri, 30 Sep 2005 09:30:09 GMT  
 Display in a text box a query

Quote:

> Txt1.Text=Rs3.Fields("Reference").Value

> If there are more than one row fetched then set the multiline property of
> the text box to true, loop through the recordset
> and

> txt1.Text=Rs3.Fields("Reference").Value & vbcrlf

> --
> Regards

> Sukesh Hoogan

> http://personal.vsnl.com/sukesh_hoogan

    Hi,
    Thanks!

    Enclose Combo1.Text within single quotes, if the value in it is
not numeric.
    But if the value in the combo1 is a date format like 4/14/2002?
does it need single quotes?
Because I try to do this with and without single quotes and the result
of the query was o :(

    Regards,

         Pucca



Sat, 01 Oct 2005 03:06:30 GMT  
 Display in a text box a query
Dates need to be enclosed in hash sign #

WHERE SomeDateField =#" & Combo1.Text & "#"

--
Regards

Sukesh Hoogan

http://personal.vsnl.com/sukesh_hoogan



Quote:
> > Txt1.Text=Rs3.Fields("Reference").Value

> > If there are more than one row fetched then set the multiline property
of
> > the text box to true, loop through the recordset
> > and

> > txt1.Text=Rs3.Fields("Reference").Value & vbcrlf

> > --
> > Regards

> > Sukesh Hoogan

> > http://personal.vsnl.com/sukesh_hoogan

>     Hi,
>     Thanks!

>     Enclose Combo1.Text within single quotes, if the value in it is
> not numeric.
>     But if the value in the combo1 is a date format like 4/14/2002?
> does it need single quotes?
> Because I try to do this with and without single quotes and the result
> of the query was o :(

>     Regards,

>          Pucca

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.471 / Virus Database: 269 - Release Date: 10/04/2003


Sat, 01 Oct 2005 10:16:39 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. Displaying result of SQL query in a text box

2. SQL query result display (text box)

3. Text Box Entry To Text Box Display?

4. Dialog box displayed during query insert or query update

5. Displaying Records in List Box as Data is input to Text Box on Form

6. Rich Text Box / Word box etc that displays tables etc

7. reading a text file to display in text box

8. Rich Text box displaying last inserted text?

9. grabbing text and displaying it in a text box

10. Displaying text in a multiline text box

11. Text Box Text Displays Question

12. Display Text from variable in text box

 

 
Powered by phpBB® Forum Software