Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Referencing a report control using ADO

Status
Not open for further replies.

CynthyJ

Programmer
Jun 30, 2003
1
US
This is my first time using ADO instead of DAO. All of the statements compile and work (I used breakpoints/watch to ensure that they are working) EXCEPT moving data from my recordset to a textbox on a report.

Can someone tell me the correct syntax for moving data from a recordset to a textbox on a report?


Dim rst As ADODB.Recordset
Dim rpt As Report
Dim fldDEA_No As ADODB.Field


Dim strDEA_No As String
Dim strCustomerName As String

Set rst = New ADODB.Recordset
Set rst.ActiveConnection = CurrentProject.Connection
Set rpt = Reports(rptHistoricalDCAllocations)

rst.Open "tblrptDCUncommitedSplitsandHistory", _
CurrentProject.Connection, CursorType = adOpenForwardOnly

rst.MoveFirst

'Me.Controls(rptDEA_No).ControlSource = rst![DEA_No] 'this syntax doesn't work at all

Set fldDEA_No = rst![DEA_No] 'this works just fine
rpt.rptDEA_No = fldDEA_No 'this syntax doesn't work


Do While Not rst.EOF
If rst.EOF Then
Exit Do
Else
rst.MoveNext

End If
Loop
rst.Close

 
Do you really want change the value only:

with Me.Controls(rptDEA_No)
.SetFocus ' a must in ACCESS
.Text = rst![DEA_No] 'this syntax doesn't work at all
end with

If you use "'Me.Controls(rptDEA_No).ControlSource = rst![DEA_No] 'this syntax doesn't work at all
make sure the rst![dea_no] is a field name in the current data (rowsource) of the form.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top