This code does not work.

  • Thread starter Thread starter TC
  • Start date Start date
Private Sub Report_Open(Cancel As Integer)
Dim ClientsRS As ADODB.Recordset
Set ClientsRS = CurrentDb.OpenRecordset("Clients")
ClientsRS.Open ("Clients")
End Sub

Can someone send me some code that will?
 
Private Sub Report_Open(Cancel As Integer)
Dim ClientsRS As ADODB.Recordset
Set ClientsRS = CurrentDb.OpenRecordset("Clients")
ClientsRS.Open ("Clients")
End Sub

Can someone send me some code that will?

That would depend on what you wanted it to do, wouldn't it? On the off
chance that you want to open a DAO recordset, you could try

Dim ClientsRS As DAO.Recordset
Set ClientsRS = CurrentDb.OpenRecordset("Clients")

Though why you would be opening it in your report's Open event, but not
doing anything with it, is a mystery.

One could alternatively guess that you wanted to open an ADODB
recordset, in which case it might be like this (though I'm not all that
familiar with ADO):

Dim ClientsRS As ADODB.Recordset
ClientsRS.Open "Clients", CurrentProject.Connection, , , adCmdTable

But really, your question amounts to "My car doesn't work. What's wrong
with it?"
 
Why don't to just set the Record Source for the Report to the Table o
Query named "Clients" ??

RD
 
You are not very clear on what you are trying to accomplish.
Are you trying just to open a report or are you trying to
dynamically set the recordset of the report? If it is the
latter, this should work...

Me.RecordSource = "Clients"

--

Gary Miller
Gary Miller Computer Services
Sisters, OR
________________________
 
Back
Top