Full Version: Dynamic crosstab report error
UtterAccess Discussion Forums > Microsoft® Access > Access Reports
travelerkaty
OK, now I have another question related to the MS dynamic crosstab report.

I followed their instructions (at support.microsoft.com), set up a form with unbound text boxes for my criteria, set up the forms!formname!controlname in the parameters and in the criteria on my xtab query.

Then I went through their whole rigamarole of Code and Event Procedures and such, putting in my own form names and such.

It's not working, however, and since I don't know much about this process, I can't figure out why. When I open the report I"m getting this message: Run-time error '2450': MS Access can't find the form 'WXReportFilter' referred to in a macro expresson or VB code.

The code to which it directs me is this:

_________________________________________

Private Sub Report_Open(Cancel As Integer)

' Create underlying recordset for report using criteria entered in
' WxReportFilter form.

Dim intX As Integer
Dim qdf As QueryDef
Dim frm As Form

' Set database variable to current database.
Set dbsReport = CurrentDb
Set frm = Forms!WxReportFilter
' Open QueryDef object.
Set qdf = dbsReport.QueryDefs("[WX report query hours xtab test 3b]")
' Set parameters for query based on values entered
' in WXReportFilter form.
qdf.Parameters("Forms!WxReportFilter!begindate") _
= frm!begindate
qdf.Parameters("Forms!WxReportFilter!enddate") _
= frm!enddate
qdf.Parameters("Forms!WxReportFilter!ponumber") _
= frm!ponumber


' Open Recordset object.
Set rstReport = qdf.OpenRecordset()

' Set a variable to hold number of columns in crosstab query.
intColumnCount = rstReport.Fields.Count

End Sub

____________________________

My form is called WxReportFilter, I named it that when I did "save" when I created it. I can't figure out within the form if there's another place where I'm supposed to name it so that it can be found.

Maybe I don't completely understand "controlname'?

Any suggestions?
fkegley
The form will need to be open for you to reference its controls.
travelerkaty
OK, I opened the form first (though I don't quite understand why the extensive code I copied off the MS article didn't open the stupid form like it should have) and now I'm getting another error:

Runtime error '2465':
Microsoft Access can't find the field "Head10" referred to in your expression.


Here's the code to which it refers:

Private Sub PageHeaderSection_Format(Cancel As Integer, FormatCount As Integer)

Dim intX As Integer

' Put column headings into text boxes in page header.
For intX = 1 To intColumnCount
Me("Head" + Format(intX)) = rstReport(intX - 1).Name
Next intX

' Make next available text box Totals heading.
Me("Head" + Format(intColumnCount + 1)) = "Totals"

' Hide unused text boxes in page header.
For intX = (intColumnCount + 2) To conTotalColumns
Me("Head" + Format(intX)).Visible = False
Next intX

End Sub

______________________

Any thoughts? I'm kind of regretting starting this process, but it would be nice to be able to have dynamic column headings for my xtab reports.


Thanks!
dazed.gif
fkegley
Yes, I think this is the correct syntax for referencing a control whose name you have constructed via code:

Dim CtlName As String

CtlName = "Head" & Trim(CStr(intX))

Me.Controls(ctlName)= rstReport(intX - 1).Name

Edited by: fkegley on Fri May 19 15:40:46 EDT 2006.
travelerkaty
Well, I can't get that to work. I think that although I would love to be able to get this thing working, it's just way too advanced for me. I don't really understand much of the code, and it's impossible for me to figure out what might work. So thanks for trying, but I'm going to table this until I go to Access University.

Katy thanks.gif
fkegley
This site is the closest thing to a Access University there is.

You might want to try posting a database with sample data. SOMEBODY here can help you.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.