Im trying to get a report to work in an “unbound” (no connection specified) Access 2000 adp, which is based on a view (or stored procedure, or SQL statement, I’m not picky here).
I created the report in a “bound” adp, where it works, then imported it into the unbound adp, where I deleted the report’s Record Source (I also deleted each control’s Control Source when this didn’t work).
I tried to get the report to display using the same (ADO) mechanism I use to with my unbound forms:
Set cmd = New ADODB.Command
Set cmd.ActiveConnection = cnn
cmd.CommandText = “procWhatever”
cmd.CommandType = adCmdStoredProc
Set prm = …
cmd.Parameters.Append prm
Set rst = New ADODB.Recordset
With rst
.CursorLocation = adUseClient
.LockType = adLockOptimistic
.Open cmd
End With
If the default view is ‘Continuous Form’, I keep the control’s Control Source, and populate it as follows:
Set Me.Recordset = rst
This doesn’t work at all in the report. Neither does Set Me.RecordSource = rst.
Neither does Me.RecordSource = rst.Name (http://www.mvps.org/access/reports/rpt0014.htm).
If the default view is ‘Single Form’, I delete the control’s Control Source (unbound), and populate it by looping through the recordset and the controls collection, and assigning the values accordingly:
With rst
If Not .BOF And Not .EOF Then
For Each ctl In Form.Section(0).Controls (which I change to ‘For Each ctl In Report.Controls’)
If ctl.ControlType = acTextBox And ctl.tag “x” Then
ctl.Value = rst(ctl.Name)
End If
Next ctl
End If
End With
Again, no such luck in my report (with or without the control’s Control Source).
Can you please point me in the right direction. I can’t find anything on this topic searching hi & lo. Much obliged.
Klaus