Here is my code for the form in which the data repeater exisits. This is where I call my connection string (global variable) and set up the datasource for my ADO data control. Then I set up the Data Repeater (Data1) using code (I have tried this both ways, using the properties and by using the code, neither on works).
Thanks!!
Option Explicit
Dim myRecordset As ADODB.Recordset
Dim myConnection As ADODB.Connection
Dim Counter As Integer
Private Sub Form_Load()
Counter = 0
Adodc1.ConnectionString = gstrConnectionString 'global variable for my connect string
Adodc1.RecordSource = gstrWhereInventory 'global variable for my database query
Set myConnection = New ADODB.Connection
Set myRecordset = New ADODB.Recordset
myConnection.ConnectionString = gstrConnectionString
myConnection.Open
myRecordset.MaxRecords = 1000
myRecordset.Open gstrWhereInventory, myConnection
Set Adodc1.Recordset = myRecordset
ConfigureDataRepeater Data1 'Data1 is my repeater
'myRecordset.Close
'myConnection.Close
Do Until myRecordset.EOF
'frmList.List1.AddItem myRecordset!Description
Counter = Counter + 1
myRecordset.MoveNext
Loop
frmList1.Label1.Caption = Counter & " Records Found"
End Sub
Private Sub ConfigureDataRepeater(Data1 As DataRepeater)
With Data1
Set .DataSource = Adodc1
' Be sure to set the RepeatedControlName before adding
' RepeaterBinding objects to the collection. Otherwise
' the DataRepeater doesn't know what public properties
' are available for binding.
.RepeatedControlName = "controlPrj.pubCtl"
.RepeaterBindings.Add "Itemnum", "ITEMNUM"
.RepeaterBindings.Add "Description", "DESCRIPTION"
.RepeaterBindings.Add "In1", "IN1"
.RepeaterBindings.Add "In2", "IN2"
.RepeaterBindings.Add "Il5", "IL5"
.RepeaterBindings.Add "Binnum", "BINNUM"
.RepeaterBindings.Add "Il4", "IL4"
.RepeaterBindings.Add "Curbal", "CURBAL"
.RepeaterBindings.Add "Issueunit", "ISSUEUNIT"
End With
End Sub
Private Sub Form_Unload(Cancel As Integer)
myRecordset.Close
myConnection.Close
End Sub
Brad Pitcher
The Hoover Company
bpitcher@hoover.com