Report Procedure Error

J

Jimmy

Hi,

I have created a dynamic crosstab report using the sample code from the MSDN
KB. This works fine, although I have modified the report-Open event to this :

Dim intX As Integer, qdf As queryDef, frm As Form, cmb As ComboBox

Set dbsReport = CurrentDb 'dbs Report declared in General Declarations
Set frm = Forms!FrmUpdate
Set cmb = Forms!FrmUpdate!Combo17

Select case cmb.Value

Case "Initial Report"
Me.RecordSource = "QryMSC"
set qdf = dbsReport.QueryDefs("QryMSC")
set qdf.Parameters("Forms!FrmUpdate!Combo1") = frm!Combo1
set qdf.Parameters("Forms!FrmUpdate!Combo3") = frm!Combo3

Case x,y,z etc.
End Select

Set rstReport = qdf.OpenRecordset() 'rstReport declared in General
Declarations
intColumnCount = rstReport.Fields.Count

The problem is for each case I have to keep typing the same code to change
the recordsource and query to match the selection of the combobox. This has
worked so far but I want to put this code into a procedure. I have copied in
whats necessary but keepgetting a runt-time error 91, I have checked and all
declarations appear present. Could anyone suggest a way of putting the code
from the case statement into a procedure that I could re-use?

Thanks in advance, Jimmy.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top