DataList won't fill??? 
Author Message
 DataList won't fill???

DataList won't fill???

I am converting from an ADO control. The last lines in the load statement are
intended to bind the DataList1 to the ADO recordset (rsADO). This worked and
automatically filled the list with the control but now the list turns up
empty. What am I doing wrong?

TIA for any help.

Private cnADO As adodb.Connection
Private rsADO As adodb.Recordset

Private Sub Form_Load()
    Dim x As Long
    Dim temp As String

    ' create new connection and new recordset
    Set cnADO = New adodb.Connection
    Set rsADO = New adodb.Recordset

    With cnADO
        .ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=C:\New\Temp3\X10.mdb;Persist Security Info=False"
        ' open the connection
        .Open
    End With

    With rsADO
        .ActiveConnection = cnADO
        ' use a lock type other than the default (readOnly) if you
        ' want to be able to update the recordset.
        .LockType = adLockOptimistic
        ' Open the recordset with the SQL command you want
        .Open "Select * From Devices"
    End With

    ' Bind your data controls...
    ' Since the recordset is produced by code, the data
    ' bindings must be set at run time.

'******* I think the problem is here where I am binding
'******* The database has "ID" and "Name" fields

    With DataList1
        Set .DataSource = rsADO
        Set .RowSource = rsADO
        .DataField = "Name"
        .ListField = "Name"
        .BoundColumn = "ID"
    End With

End Sub

--
yabba
===========================
yabbadoo<at>bigfoot<dot>com



Tue, 16 Apr 2002 03:00:00 GMT  
 DataList won't fill???
You might try datalist1.refresh or datalist1.refill after all the other
stuff.

Quote:
> DataList won't fill???

> I am converting from an ADO control. The last lines in the load statement
are
> intended to bind the DataList1 to the ADO recordset (rsADO). This worked
and
> automatically filled the list with the control but now the list turns up
> empty. What am I doing wrong?

> TIA for any help.

> Private cnADO As adodb.Connection
> Private rsADO As adodb.Recordset

> Private Sub Form_Load()
>     Dim x As Long
>     Dim temp As String

>     ' create new connection and new recordset
>     Set cnADO = New adodb.Connection
>     Set rsADO = New adodb.Recordset

>     With cnADO
>         .ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data
> Source=C:\New\Temp3\X10.mdb;Persist Security Info=False"
>         ' open the connection
>         .Open
>     End With

>     With rsADO
>         .ActiveConnection = cnADO
>         ' use a lock type other than the default (readOnly) if you
>         ' want to be able to update the recordset.
>         .LockType = adLockOptimistic
>         ' Open the recordset with the SQL command you want
>         .Open "Select * From Devices"
>     End With

>     ' Bind your data controls...
>     ' Since the recordset is produced by code, the data
>     ' bindings must be set at run time.

> '******* I think the problem is here where I am binding
> '******* The database has "ID" and "Name" fields

>     With DataList1
>         Set .DataSource = rsADO
>         Set .RowSource = rsADO
>         .DataField = "Name"
>         .ListField = "Name"
>         .BoundColumn = "ID"
>     End With

> End Sub

> --
> yabba
> ===========================
> yabbadoo<at>bigfoot<dot>com



Tue, 16 Apr 2002 03:00:00 GMT  
 DataList won't fill???

I had that in at one time and it didn't help.

Thanks,

yabba


says...

Quote:

>You might try datalist1.refresh or datalist1.refill after all the other
>stuff.


>> DataList won't fill???

>> I am converting from an ADO control. The last lines in the load statement
>are
>> intended to bind the DataList1 to the ADO recordset (rsADO). This worked
>and
>> automatically filled the list with the control but now the list turns up
>> empty. What am I doing wrong?

>> TIA for any help.

>> Private cnADO As adodb.Connection
>> Private rsADO As adodb.Recordset

>> Private Sub Form_Load()
>>     Dim x As Long
>>     Dim temp As String

>>     ' create new connection and new recordset
>>     Set cnADO = New adodb.Connection
>>     Set rsADO = New adodb.Recordset

>>     With cnADO
>>         .ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data
>> Source=C:\New\Temp3\X10.mdb;Persist Security Info=False"
>>         ' open the connection
>>         .Open
>>     End With

>>     With rsADO
>>         .ActiveConnection = cnADO
>>         ' use a lock type other than the default (readOnly) if you
>>         ' want to be able to update the recordset.
>>         .LockType = adLockOptimistic
>>         ' Open the recordset with the SQL command you want
>>         .Open "Select * From Devices"
>>     End With

>>     ' Bind your data controls...
>>     ' Since the recordset is produced by code, the data
>>     ' bindings must be set at run time.

>> '******* I think the problem is here where I am binding
>> '******* The database has "ID" and "Name" fields

>>     With DataList1
>>         Set .DataSource = rsADO
>>         Set .RowSource = rsADO
>>         .DataField = "Name"
>>         .ListField = "Name"
>>         .BoundColumn = "ID"
>>     End With

>> End Sub

>> --
>> yabba
>> ===========================
>> yabbadoo<at>bigfoot<dot>com

--
yabba
===========================
yabbadoo<at>bigfoot<dot>com


Tue, 16 Apr 2002 03:00:00 GMT  
 DataList won't fill???
Hi,

Can try the use of a data class object instead, like:

Option Explicit

Private Sub Form_Load()
    Dim MyDataClass As New CSimpleData  ' Data class object

    With Me.DataList1
        .ListField = "Selection"
        .BoundColumn = "FormeID"
        .RowMember = "FormesDeCharge"   ' The table name
        Set .RowSource = MyDataClass
    End With

End Sub

And my data class code is just:
===================================
Option Explicit
Private cnn As ADODB.Connection
Private WithEvents rs As ADODB.Recordset
------------------------------------
Private Sub Class_GetDataMember(DataMember As String, Data As Object)
    Set rs = New ADODB.Recordset

    Select Case DataMember
    Case ""             ' Default
        Set Data = Nothing
    Case Else
        rs.Open DataMember, cnn, adOpenStatic, adLockOptimistic, adCmdTable
        Set Data = rs
    End Select

End Sub
------------------------------------------
Private Sub Class_Initialize()
    Set cnn = GetGlobalConnexion()    ' My function to open the typical
connection
    cnn.Open
End Sub
-----------------------------------------
Private Sub Class_Terminate()
    If Not (rs Is Nothing) Then
        If adStateOpen = (rs.State And adStateOpen) Then
            rs.Close
        End If
        If Not rs Is Nothing Then Set rs = Nothing
    End If

    If adStateOpen = (cnn.State And adStateOpen) Then
        cnn.Close
    End If

    If Not cnn Is Nothing Then Set cnn = Nothing

End Sub
===========================

If you don't use the Wizard, don't forget to set DataSourceBehavior at
vbDataSource.

Hoping it may help,
Vanderghast, Access MVP.


Quote:
> DataList won't fill???

> I am converting from an ADO control. The last lines in the load statement
are
> intended to bind the DataList1 to the ADO recordset (rsADO). This worked
and
> automatically filled the list with the control but now the list turns up
> empty. What am I doing wrong?

> TIA for any help.

> Private cnADO As adodb.Connection
> Private rsADO As adodb.Recordset

> Private Sub Form_Load()
>     Dim x As Long
>     Dim temp As String

>     ' create new connection and new recordset
>     Set cnADO = New adodb.Connection
>     Set rsADO = New adodb.Recordset

>     With cnADO
>         .ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data
> Source=C:\New\Temp3\X10.mdb;Persist Security Info=False"
>         ' open the connection
>         .Open
>     End With

>     With rsADO
>         .ActiveConnection = cnADO
>         ' use a lock type other than the default (readOnly) if you
>         ' want to be able to update the recordset.
>         .LockType = adLockOptimistic
>         ' Open the recordset with the SQL command you want
>         .Open "Select * From Devices"
>     End With

>     ' Bind your data controls...
>     ' Since the recordset is produced by code, the data
>     ' bindings must be set at run time.

> '******* I think the problem is here where I am binding
> '******* The database has "ID" and "Name" fields

>     With DataList1
>         Set .DataSource = rsADO
>         Set .RowSource = rsADO
>         .DataField = "Name"
>         .ListField = "Name"
>         .BoundColumn = "ID"
>     End With

> End Sub

> --
> yabba
> ===========================
> yabbadoo<at>bigfoot<dot>com



Fri, 19 Apr 2002 03:00:00 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. DataList won't fill???

2. DataList won't fill???

3. DataList Control won't match user's keystrokes when list too long

4. DataList Control won't match user's keystrokes when list too long

5. Child forms won't load in MDI with gradient fill

6. Main window which won't fill down screen when maximized

7. ODBCDirect - MSFlex won't fill from data control

8. Filling multiple datalist boxes - Newbie

9. MSINET.OCX *still* won't register, and now IE4 won't install

10. Help moving items in a DataList to Another DataList

11. Why can't 2 datalist controls be on 1 form

12. Moving from Win 3.11 to Win NT ?'s

 

 
Powered by phpBB® Forum Software