Welcome to dbFreaks.com!
FAQFAQ    SearchSearch      ProfileProfile    Private MessagesPrivate Messages   Log inLog in

ListBox with ADODC

 
   Database Help (Home) -> Visual Basic -> ADO RSS
Next:  newbie - late bind datalist doesn't populate  
Author Message
Bharat Mehta

External


Since: Feb 14, 2005
Posts: 2



(Msg. 1) Posted: Mon Feb 14, 2005 2:40 pm
Post subject: ListBox with ADODC
Archived from groups: microsoft>public>vb>database>ado (more info?)

I am using ADODatacontrol in my form, when I link TextBox with ADODC it
shows me the records, but when I link this ADODC with ListBox it does not
show any data. Please advice.

 >> Stay informed about: ListBox with ADODC 
Back to top
Login to vote
Newbee Adam

External


Since: Feb 14, 2005
Posts: 3



(Msg. 2) Posted: Mon Feb 14, 2005 2:40 pm
Post subject: RE: ListBox with ADODC [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

i am having the same problem now. But I am binding in control in the code.
My ADO vb 6 programming book says that the listbox control will not
automatically be populated and you will have to use the additem method.
The book ssuggesting using the datalist control. To do this, you have to go
to project > compononents and check the Microsoft datalist controls check box.
Then drag it from your toolbox to form.
However, I still am not getting it to populate the datalist but like you
have no problem getting it to populate my text box.
I guess my best help to you is moral support and to let you know you need to
use a different control as I was directed to, or us the additem method using
a do/whiule loop.

this code is to populate a listbox from a databse table using the standard
data control, I am not sure if it will work with the adocontrol , but I am
about to try myself I think.


with datacontrol1
.Refresh 'open database

Do Until .Recordset.EOF 'fill the listbox
If .Recordset!Field <> "" Then
listbox.AddItem.Recordset!Field
End If
.RecordSet.MoveNext
Loop
End With






let me no if you figure it out.


"Bharat Mehta" wrote:

 > I am using ADODatacontrol in my form, when I link TextBox with ADODC it
 > shows me the records, but when I link this ADODC with ListBox it does not
 > show any data. Please advice.
 >
 >
 >

 >> Stay informed about: ListBox with ADODC 
Back to top
Login to vote
user1891

External


Since: Dec 09, 2004
Posts: 8



(Msg. 3) Posted: Mon Feb 14, 2005 5:40 pm
Post subject: Re: ListBox with ADODC [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

A good advise. Forget DataContol and AdoDataControl in your project.

Open Project, add command button and combobox



Public MyConn As New ADODB.Connection
Private Sub Command1_Click()

MyConn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=MyDatabase.mdb;Persist Security Info=False"
Set rs = MyConn.Execute("SELECT MyField FROM MyTable GROUP BY MyField")

Combo1 = rs("MyField")

With rs
If Not .EOF Then
Do While Not .EOF
Combo1.AddItem rs("MyField")
.movenext
Loop
End If
End With
Set rs = Nothing
Set MyConn = Nothing


End Sub
 >> Stay informed about: ListBox with ADODC 
Back to top
Login to vote
Bharat Mehta

External


Since: Feb 14, 2005
Posts: 2



(Msg. 4) Posted: Thu Feb 17, 2005 2:40 pm
Post subject: Re: ListBox with ADODC [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Thanks Leclercq

It Works as per your suggetion

Bharat Mehta

"Gérard Leclercq" wrote in message

 > A good advise. Forget DataContol and AdoDataControl in your project.
 >
 > Open Project, add command button and combobox
 >
 >
 >
 > Public MyConn As New ADODB.Connection
 > Private Sub Command1_Click()
 >
 > MyConn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data
 > Source=MyDatabase.mdb;Persist Security Info=False"
 > Set rs = MyConn.Execute("SELECT MyField FROM MyTable GROUP BY MyField")
 >
 > Combo1 = rs("MyField")
 >
 > With rs
 > If Not .EOF Then
 > Do While Not .EOF
 > Combo1.AddItem rs("MyField")
 > .movenext
 > Loop
 > End If
 > End With
 > Set rs = Nothing
 > Set MyConn = Nothing
 >
 >
 > End Sub
 >
 >
 >
 >
 >
 >
 >
 >
 >
 >> Stay informed about: ListBox with ADODC 
Back to top
Login to vote
Excalibur Software

External


Since: Feb 22, 2005
Posts: 1



(Msg. 5) Posted: Tue Feb 22, 2005 3:14 am
Post subject: Re: ListBox with ADODC [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Bharat Mehta wrote:
 > *I am using ADODatacontrol in my form, when I link TextBox with ADODC
 > it
 > shows me the records, but when I link this ADODC with ListBox it does
 > not
 > show any data. Please advice. *

Here is another way you may place data in a combox

Dim cn As New ADODB.Connection
Dim RS As New ADODB.Recordset
Dim MySQLString As String

cn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & _
App.Path & "\YourDatabaseNAme.mdb;Persist Security " & _
"Info=False"

With Adodc1
RecordSource = _
"SELECT TableName.FieldName1, TableName.FieldName2" & _
" FROM TableName "
ConnectionString = cn
Refresh
Caption = "Items"
Visible = False
End With

RS.Close
cn.Close

If I can help anymore please let me know



--
Excalibur Software
------------------------------------------------------------------------
Posted via <a rel="nofollow" style='text-decoration: none;' href="http://www.codecomments.com" target="_blank">http://www.codecomments.com</a>
------------------------------------------------------------------------
 >> Stay informed about: ListBox with ADODC 
Back to top
Login to vote
Display posts from previous:   
Related Topics:
ADODC Query Problem - I have a VB6 form with several text boxes I would like to use to display data stored in an Access db. I've used ADODC to bind the appropriate form fields to the recordsource fields. If I use the ADODC in adcmdTable mode, I get all the records and it...

runtime error 3021 and user permissions - I have a VB6 application that uses ADO 2.7 to access an Access2000 database. I have found on Windows XP and 2000, that if the user is not part of the administrators group, they receive: "runtime error 3021. Either BOF or EOF is true, or the current ...

updatable ado-recordset - Hi, In the code below i have an updatable ado-recordset. However it is not working how i thought it would be. Maybe someone can help me out here? The global connection (Thanks to Brendan): Option Compare Database Option Explicit Public mconn As..

ADO Connection Access Database VB - I have been accessing a database on a local drive thru an ADO connection. The following is the code that I have been using. cnCejco.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=Y:\Cejco.mdb;Persist Security Info=False" The problem is n...

DataReport PageBreak - Hi everyone, I would like to know how to force pagebreak in a datareport for example after 5 records printed. Thank you all
   Database Help (Home) -> Visual Basic -> ADO All times are: Pacific Time (US & Canada)
Page 1 of 1

 
You can post new topics in this forum
You can reply to topics in this forum
You can edit your posts in this forum
You can delete your posts in this forum
You can vote in polls in this forum



[ Contact us | Terms of Service/Privacy Policy ]