Ladyoftheputers
New member
- Local time
- Today, 03:39
- Joined
- Sep 29, 2011
- Messages
- 6
Hello! New to the forum, but not programming nor Access. I'm still kinda "old" skewel in Access & programming, but trying to catch up! I hesitated to post as this will be rather long but, since I'm banging my head!!! Anyway, my prob... I've 'migrated' a db from A97 to 2007. After several months, I've FINALLY got it compressed, compiled & working (mostly) in 2007! I said mostly because there are a few probs.. the main one which is really bugging me is this 3079 error... it says that my specified field could refer to more than one table listed in the FROM clause of my SQL. Okay, I could understand that under normal circumstances, but the thing is....this field is only in two tables in the entire db...and only one table that has that field is being referenced anywhere in any of the SQL statements. The error is coming when I have a popup that a user selects which date range they want to use to print the report. The VBA line is:
DoCmd.OpenReport "MBookings", acViewPreview, "MBookingsQuery", "(([Status.StatusCode] = 'S') AND (([MBookingsQuery]![Jobs.ResolutionsDate]) >= [Forms]![frmReportDateRanges]![txtBeginDate]) AND (([MBookingsQuery]![Jobs.ResolutionDate]) <= [Forms]![frmReportDateRanges]![txtEndDate]))"
The field is "Jobs.ResolutionsDate". The criteria query is:
SELECT DISTINCTROW Status.StatusCode, Status.StatusName, Employees.LastName, Employees.FirstName, Jobs.ResolutionDate, PContracts.ContractNumber, Jobs.JobID, Jobs.LocationID, Jobs.JobName, Jobs.BaseBid AS OldBaseBid, IIf((IsNull([CalcTotal])),[OldBaseBid],[CalcTotal]) AS BaseBid, [RegUndecMat]+[RegUndecTax]+[RegUndecLabor]+[RegUndecTON]+[RegUndecSubcontracts]+[RegUndecGM] AS CalcTotal, Jobs.GrossMargin, Jobs.ManDays, Locations.LocationName, IIf([BaseBid]=0,"0",[GrossMargin]/[BaseBid]) AS [GM%], IIf((IsError([GrossMargin]/[ManDays])),0,[GrossMargin]/[ManDays]) AS [GM/MD], PContracts.CustomerID, Customers.CustomerName, Customers.CustCode, Employees.EmployeeCode
FROM Customers RIGHT JOIN (((Status INNER JOIN (Locations INNER JOIN (Employees INNER JOIN Jobs ON Employees.EmployeeID = Jobs.EmployeeID) ON Locations.LocationID = Jobs.LocationID) ON Status.StatusID = Jobs.StatusID) INNER JOIN PContracts ON Jobs.JobID = PContracts.JobID) LEFT JOIN qryRegUndecTotals ON PContracts.ContractNumber = qryRegUndecTotals.ContractNumber) ON Customers.CustomerID = PContracts.CustomerID
ORDER BY Employees.LastName, Jobs.ResolutionDate, PContracts.ContractNumber, Jobs.JobID;
Yes, it has another query, which is:
SELECT DISTINCTROW qryInvoiceTotals.ContractNumber, IIf((IsNull([qryUndecidedTotals]![SumOfMaterial])),[qryInvoiceTotals]![SumOfMaterial],([qryInvoiceTotals]![SumOfMaterial]+[qryUndecidedTotals]![SumOfMaterial])) AS RegUndecMat, IIf((IsNull([qryUndecidedTotals]![SumOfTax])),[qryInvoiceTotals]![SumOfTax],([qryInvoiceTotals]![SumOfTax]+[qryUndecidedTotals]![SumOfTax])) AS RegUndecTax, IIf((IsNull([qryUndecidedTotals]![SumOfLabor])),[qryInvoiceTotals]![SumOfLabor],([qryInvoiceTotals]![SumOfLabor]+[qryUndecidedTotals]![SumOfLabor])) AS RegUndecLabor, IIf((IsNull([qryUndecidedTotals]![SumOfTrips&O/N])),[qryInvoiceTotals]![SumOfTrips&O/N],([qryInvoiceTotals]![SumOfTrips&O/N]+[qryUndecidedTotals]![SumOfTrips&O/N])) AS RegUndecTON, IIf((IsNull([qryUndecidedTotals]![SumOfSubcon])),[qryInvoiceTotals]![SumOfSubcontracts],([qryInvoiceTotals]![SumOfSubcontracts]+[qryUndecidedTotals]![SumOfSubcon])) AS RegUndecSubcontracts, IIf((IsNull([qryUndecidedTotals]![SumOfGM])),[qryInvoiceTotals]![SumOfGM],([qryInvoiceTotals]![SumOfGM]+[qryUndecidedTotals]![SumOfGM])) AS RegUndecGM, IIf((IsNull([qryUndecidedTotals]![SumOfMDFab])),[qryInvoiceTotals]![SumOfFabMDs],([qryInvoiceTotals]![SumOfFabMDs]+[qryUndecidedTotals]![SumOfMDFab])) AS RegUndecFabMD, IIf((IsNull([qryUndecidedTotals]![SumOfMDInstall])),[qryInvoiceTotals]![SumOfInstallMDs],([qryInvoiceTotals]![SumOfInstallMDs]+[qryUndecidedTotals]![SumOfMDInstall])) AS RegUndecInstMD
FROM (PContracts LEFT JOIN qryInvoiceTotals ON PContracts.ContractNumber=qryInvoiceTotals.ContractNumber) LEFT JOIN qryUndecidedTotals ON PContracts.ContractNumber=qryUndecidedTotals.ContractNumber
ORDER BY qryInvoiceTotals.ContractNumber;
Okay, by now you should trust me when I say that there are only 2 tables with this field name and only 1 is being referenced.
If there is anyone still with me...any ideas? Oh, in the 97 version, this works.
Thanks in advance for any help or ideas!
BTW: The queries all run. Another place this report is printed with date ranges input by user and it runs perfectly. Alas, it is not being called thru VB but by a macro. It's called by VB here(I think - this isn't my code, I'm just band-aiding!) because it is just the first of several reports being called and printed at once using the same date range.
DoCmd.OpenReport "MBookings", acViewPreview, "MBookingsQuery", "(([Status.StatusCode] = 'S') AND (([MBookingsQuery]![Jobs.ResolutionsDate]) >= [Forms]![frmReportDateRanges]![txtBeginDate]) AND (([MBookingsQuery]![Jobs.ResolutionDate]) <= [Forms]![frmReportDateRanges]![txtEndDate]))"
The field is "Jobs.ResolutionsDate". The criteria query is:
SELECT DISTINCTROW Status.StatusCode, Status.StatusName, Employees.LastName, Employees.FirstName, Jobs.ResolutionDate, PContracts.ContractNumber, Jobs.JobID, Jobs.LocationID, Jobs.JobName, Jobs.BaseBid AS OldBaseBid, IIf((IsNull([CalcTotal])),[OldBaseBid],[CalcTotal]) AS BaseBid, [RegUndecMat]+[RegUndecTax]+[RegUndecLabor]+[RegUndecTON]+[RegUndecSubcontracts]+[RegUndecGM] AS CalcTotal, Jobs.GrossMargin, Jobs.ManDays, Locations.LocationName, IIf([BaseBid]=0,"0",[GrossMargin]/[BaseBid]) AS [GM%], IIf((IsError([GrossMargin]/[ManDays])),0,[GrossMargin]/[ManDays]) AS [GM/MD], PContracts.CustomerID, Customers.CustomerName, Customers.CustCode, Employees.EmployeeCode
FROM Customers RIGHT JOIN (((Status INNER JOIN (Locations INNER JOIN (Employees INNER JOIN Jobs ON Employees.EmployeeID = Jobs.EmployeeID) ON Locations.LocationID = Jobs.LocationID) ON Status.StatusID = Jobs.StatusID) INNER JOIN PContracts ON Jobs.JobID = PContracts.JobID) LEFT JOIN qryRegUndecTotals ON PContracts.ContractNumber = qryRegUndecTotals.ContractNumber) ON Customers.CustomerID = PContracts.CustomerID
ORDER BY Employees.LastName, Jobs.ResolutionDate, PContracts.ContractNumber, Jobs.JobID;
Yes, it has another query, which is:
SELECT DISTINCTROW qryInvoiceTotals.ContractNumber, IIf((IsNull([qryUndecidedTotals]![SumOfMaterial])),[qryInvoiceTotals]![SumOfMaterial],([qryInvoiceTotals]![SumOfMaterial]+[qryUndecidedTotals]![SumOfMaterial])) AS RegUndecMat, IIf((IsNull([qryUndecidedTotals]![SumOfTax])),[qryInvoiceTotals]![SumOfTax],([qryInvoiceTotals]![SumOfTax]+[qryUndecidedTotals]![SumOfTax])) AS RegUndecTax, IIf((IsNull([qryUndecidedTotals]![SumOfLabor])),[qryInvoiceTotals]![SumOfLabor],([qryInvoiceTotals]![SumOfLabor]+[qryUndecidedTotals]![SumOfLabor])) AS RegUndecLabor, IIf((IsNull([qryUndecidedTotals]![SumOfTrips&O/N])),[qryInvoiceTotals]![SumOfTrips&O/N],([qryInvoiceTotals]![SumOfTrips&O/N]+[qryUndecidedTotals]![SumOfTrips&O/N])) AS RegUndecTON, IIf((IsNull([qryUndecidedTotals]![SumOfSubcon])),[qryInvoiceTotals]![SumOfSubcontracts],([qryInvoiceTotals]![SumOfSubcontracts]+[qryUndecidedTotals]![SumOfSubcon])) AS RegUndecSubcontracts, IIf((IsNull([qryUndecidedTotals]![SumOfGM])),[qryInvoiceTotals]![SumOfGM],([qryInvoiceTotals]![SumOfGM]+[qryUndecidedTotals]![SumOfGM])) AS RegUndecGM, IIf((IsNull([qryUndecidedTotals]![SumOfMDFab])),[qryInvoiceTotals]![SumOfFabMDs],([qryInvoiceTotals]![SumOfFabMDs]+[qryUndecidedTotals]![SumOfMDFab])) AS RegUndecFabMD, IIf((IsNull([qryUndecidedTotals]![SumOfMDInstall])),[qryInvoiceTotals]![SumOfInstallMDs],([qryInvoiceTotals]![SumOfInstallMDs]+[qryUndecidedTotals]![SumOfMDInstall])) AS RegUndecInstMD
FROM (PContracts LEFT JOIN qryInvoiceTotals ON PContracts.ContractNumber=qryInvoiceTotals.ContractNumber) LEFT JOIN qryUndecidedTotals ON PContracts.ContractNumber=qryUndecidedTotals.ContractNumber
ORDER BY qryInvoiceTotals.ContractNumber;
Okay, by now you should trust me when I say that there are only 2 tables with this field name and only 1 is being referenced.
If there is anyone still with me...any ideas? Oh, in the 97 version, this works.
Thanks in advance for any help or ideas!
BTW: The queries all run. Another place this report is printed with date ranges input by user and it runs perfectly. Alas, it is not being called thru VB but by a macro. It's called by VB here(I think - this isn't my code, I'm just band-aiding!) because it is just the first of several reports being called and printed at once using the same date range.
Last edited: