Hello
I am trying to create a recordset using the below code in a linked database in order to format a report and determine the number of columns as the report is driven by a crosstab query.
I am getting a runtime error 3066 on the bold line below: Query must have at least one destination field.
I am having a difficult time changing a bit of my code since I split the database and this is one that is giving me real trouble. Any suggestions would be tremendously helpful.
Thanks
Sean
Private Sub Report_Open(Cancel As Integer)
'Create underlying recordset for report using criteria entered on
'form.
Dim dbsReport As DAO.Database
Dim rstReport As DAO.Recordset
Dim intX As Integer
Dim qdf As QueryDef
Dim frm As Form
Dim prm As Parameter
Dim StrName As String
StrName = "C:\Users\swichman\Documents\Rosewich\RosewichData base\BackEnd\Rosewich_be.accdb"
' Set database variable to current database.
Set dbsReport = DBEngine.Workspaces(0).OpenDatabase(StrName)
Set qdf = dbsReport.QueryDefs(Me.RecordSource)
For Each prm In qdf.Parameters
prm.Value = Eval(prm.Name)
Next prm
' Open Recordset object.
Set rstReport = qdf.OpenRecordset()
' Set a variable to hold number of columns in crosstab query.
intColumnCount = rstReport.Fields.Count
End Sub