Duane,
I am looking at your crosstab.mdb solution again, but just to clarify,
I was able to get a sample report working based on the Solutions9.mdb
"Create a crosstab with dynamic column headings". The issue I am
having, and I may have not been clear about it is that I can't figure
out how to specify the parameter to my crosstab query properly.
1) If I don't set the report's Record Source property to my crosstab
query's name MyCrossTab, I don't get the results.
2) In my report's Report_Open event handler, I tried a few different
ways of creating my report's RecordSource programmatically. One way I
created a SQL string that held the contents of my crosstab query and
appended the criteria (part number) using string concatenation and an
input box prompting for the part number. The result of this was 2
dialog prompts, one from the input box and one from the reference to
the [forms]![frmDisplayQuotes]![subfDisplayQuotes].[form]![Part No]
field in the crosstab query.
The second method was to set the querydef like this Set qdf =
dbsReport.QueryDefs("MyCrossTab") and the querydef's parameter like
this:
qdf.Parameters("[Forms]![frmDisplayQuotes]![subfDisplayQuotes].[Form]![Part
No]") = [Forms]![frmDisplayQuotes]![subfDisplayQuotes].[Form]![Part
No]. This still brought up 2 prompts, but it works if I test the
report. It, however, doesn't work if I hook it up to my Access
applications main form. When I click the command button that loads the
report, my Access app just hangs. I can't figure out why.
==========================
Anyway, I'm trying to apply your Crosstab.mdb solution to my problem.
I'm trying to figure out how to build the "alias framework". I don't
quite see how my schema fits your solution. Can you help me understand
how I can accomplish this?
Your qappEmpCust query looks like this:
INSERT INTO tblEmpCustAlias ( EmployeeID, CustomerID )
SELECT tblSales.EmployeeID, tblSales.CustomerID
FROM tblSales
WHERE (((tblSales.SaleDate) Between
[Forms]![frmReportSelect]![txtStartDate] And
[Forms]![frmReportSelect]![txtEndDate]))
GROUP BY tblSales.EmployeeID, tblSales.CustomerID;
I don't know what fields should go into my alias table. Your report
has customers as column headers. I need quantities as column headers.
You report is grouped by Employee, I need my report sorted by date.
OBTW, I inherited this Access application/database and I don't have
much say in it's design/structure from a table standpoint.
For reference, here are the table structures:
============
tblQUOTECORE
============
Name Type Size
=============================================
qtQuoteNo Number (Long) 4
qtRFQDate Date/Time 8
qtQuoteDate Date/Time 8
qtSupplierID Text 15
qtRFQTo Text 50
qtRFQFrom Text 50
qtPartNo Text 50
qtRevisionNo Text 3
qtPartDescription Text 50
qtSpecialDescription Text 150
qtQTY1 Number (Long) 4
qtPrice1 Currency 8
qtQTY2 Number (Long) 4
qtPrice2 Currency 8
qtQTY3 Number (Long) 4
qtPrice3 Currency 8
qtQTY4 Number (Long) 4
qtPrice4 Currency 8
qtQTY5 Number (Long) 4
qtPrice5 Currency 8
qtToolingCost Text 50
qtToolingDescription Text 100
qtLeadTime Text 50
qtCompletedToPrint Yes/No 1
qtException_Mark Yes/No 1
qtExceptions Memo -
qtSchedProduction Date/Time 8
qtEnteredBy Text 50
qtEntryDate Date/Time 8
qtAdditionalNotes Memo -
qtQuoteStatus Yes/No 1
qtProjectNo Text 20
qtModificationDate Date/Time 8
===============
tblQUOTE_VALUES
===============
Name Type Size
=====================================
vQuoteNo Number (Long) 4
vQty Number (Double) 8
vPrice Currency 8
tblQUOTE_VALUES gets updated if following fields are populated in
tblQUOTECORE (in the Access application)
qtQTY1 Number (Long) 4
qtPrice1 Currency 8
qtQTY2 Number (Long) 4
qtPrice2 Currency 8
qtQTY3 Number (Long) 4
qtPrice3 Currency 8
qtQTY4 Number (Long) 4
qtPrice4 Currency 8
qtQTY5 Number (Long) 4
qtPrice5 Currency 8
Here is some other information that may help. I have 2 ways of getting
the data to be used for the crosstab but both seem to return the same
results when used in a crosstab:
One way is a nasty set of union queries that massages the data into a
more normalized structure (in my example for part number 4519135, 280
records):
SELECT qtQuoteNo, VENDOR_ID, VEND_NAME,
qtQTY1 As Qty, 1 as Seq, qtPrice1 as Price
FROM (tblQUOTECORE INNER JOIN VEID ON tblQUOTECORE.qtSupplierID =
VEID.VENDOR_ID) LEFT JOIN tblQUOTE_VALUES ON tblQUOTECORE.qtQuoteNo =
tblQUOTE_VALUES.vQuoteNo
Where tblQUOTECORE.qtPartNo =
[forms]![frmDisplayQuotes]![subfDisplayQuotes].[form]![Part No]
UNION ALL
SELECT qtQuoteNo, VENDOR_ID, VEND_NAME,
qtQTY2, 2 , qtPrice2
FROM (tblQUOTECORE INNER JOIN VEID ON tblQUOTECORE.qtSupplierID =
VEID.VENDOR_ID) LEFT JOIN tblQUOTE_VALUES ON tblQUOTECORE.qtQuoteNo =
tblQUOTE_VALUES.vQuoteNo
Where tblQUOTECORE.qtPartNo =
[forms]![frmDisplayQuotes]![subfDisplayQuotes].[form]![Part No]
UNION ALL
SELECT qtQuoteNo, VENDOR_ID, VEND_NAME,
qtQTY3, 3 , qtPrice3
FROM (tblQUOTECORE INNER JOIN VEID ON tblQUOTECORE.qtSupplierID =
VEID.VENDOR_ID) LEFT JOIN tblQUOTE_VALUES ON tblQUOTECORE.qtQuoteNo =
tblQUOTE_VALUES.vQuoteNo
Where tblQUOTECORE.qtPartNo =
[forms]![frmDisplayQuotes]![subfDisplayQuotes].[form]![Part No]
UNION ALL
SELECT qtQuoteNo, VENDOR_ID, VEND_NAME,
qtQTY4, 4 , qtPrice4
FROM (tblQUOTECORE INNER JOIN VEID ON tblQUOTECORE.qtSupplierID =
VEID.VENDOR_ID) LEFT JOIN tblQUOTE_VALUES ON tblQUOTECORE.qtQuoteNo =
tblQUOTE_VALUES.vQuoteNo
Where tblQUOTECORE.qtPartNo =
[forms]![frmDisplayQuotes]![subfDisplayQuotes].[form]![Part No]
UNION ALL SELECT qtQuoteNo, VENDOR_ID, VEND_NAME,
qtQTY5, 5 , qtPrice5
FROM (tblQUOTECORE INNER JOIN VEID ON tblQUOTECORE.qtSupplierID =
VEID.VENDOR_ID) LEFT JOIN tblQUOTE_VALUES ON tblQUOTECORE.qtQuoteNo =
tblQUOTE_VALUES.vQuoteNo
Where tblQUOTECORE.qtPartNo =
[forms]![frmDisplayQuotes]![subfDisplayQuotes].[form]![Part No];
The other way is to create a join query but this approach will miss
records for some quotes (in my example, 56 records)
SELECT tblQUOTECORE.qtQuoteNo, tblQUOTECORE.qtRFQDate, VEID.VENDOR_ID,
VEID.VEND_NAME, tblQUOTE_VALUES.vQty, tblQUOTE_VALUES.vPrice
FROM (tblQUOTECORE INNER JOIN tblQUOTE_VALUES ON tblQUOTECORE.qtQuoteNo
= tblQUOTE_VALUES.vQuoteNo) INNER JOIN VEID ON
tblQUOTECORE.qtSupplierID = VEID.VENDOR_ID
WHERE
(((tblQUOTECORE.qtPartNo)=[forms]![frmDisplayQuotes]![subfDisplayQuotes].[form]![Part
No]))
ORDER BY tblQUOTECORE.qtRFQDate DESC;
Anyway, if you could point me into the right direction to model my
report after your crosstab.mdb solution, I'd really appreciate it.