S
spoedniek
Hi,
I've been plodding my way through designing and implementing a database
that I need to organise my work, and I've been more successful than I
thought I'd be. That's the good bit. Now, however, I am completely
flumoxed (if that's the correct spelling), and I have been for a couple
of days now. This is the scene (bear in mind that this is my first
proper exposure to Access and databases in general):
I have a form with a button that calls up a report linked to a fairly
nasty looking query. The idea is that the button calls up an Invoice
(the report) which has to gather all the necessary information from the
database using a query. The form works, the report works and the query
works. But they don't work together. I'm using Access2002.
The query looks like this (appologies for the length/size but I'm
posting it since I suspect it may be the query that's the problem):
SELECT
tProject.projID, First(tProject.title) AS Project,
First(tProject.clientRefNum) AS Reference, First(tDeliverable.name) AS
Deliverable, First(tProcess.name) AS Process, Avg(tProcess.rates) AS
Rates, Sum(DateDiff("n",tTimeStamp.timeStart,tTimeStamp.timeStop)) AS
Minutes,
Round(Sum(DateDiff("n",tTimeStamp.timeStart,tTimeStamp.timeStop))/60)
AS Hours,
(Round(Sum(DateDiff("n",tTimeStamp.timeStart,tTimeStamp.timeStop))/60))*First(tProcess.rates)
AS Cost, First(tClients.CompanyName) AS Company,
First(tClients.VatNumber) AS [VAT Number], First(tContacts.firstName) &
" " & First(tContacts.lastName) AS [Contact Name],
First(tAddresses.Address) AS Address, First(tAddresses.City) AS City,
First(tAddresses.PostalCode) AS [Postal Code],
First(tAddresses.Province) AS Province, First(tAddresses.Phone) AS
Phone, First(tAddresses.FaxNumber) AS Fax, Min(tTimeStamp.timeStart) AS
MinOftimeStart
FROM
(tContacts INNER JOIN ((tClients INNER JOIN (tAddresses INNER JOIN
txAddressClient ON tAddresses.AddressID=txAddressClient.addressID) ON
tClients.clientID=txAddressClient.clientID) INNER JOIN tProject ON
tClients.clientID=tProject.clientID) ON
tContacts.contactID=tProject.contactPrimary) INNER JOIN ((tDeliverable
INNER JOIN tProcess ON tDeliverable.delivID=tProcess.delivID) INNER
JOIN tTimeStamp ON tProcess.processID=tTimeStamp.procID) ON
tProject.projID=tDeliverable.projID
GROUP BY tProject.projID, tProcess.processID, tDeliverable.delivID;
The query works. When I add parameters for the period for which I want
to display the invoice, it still works and produces the desired
results. Here's the WHERE clause I added to test:
WHERE tTimeStamp.timeStart BETWEEN [Start of period:] AND [End of
period:]
The report (rInvoice) works perfectly (only quite perfectly, I fear)
with this query (with or without the WHERE clause).
In the form, using the query without the WHERE clause above, I call the
report with the following (what I presume to be standard) code:
Private Sub btnViewInvoice_Click()
On Error GoTo Err_btnViewInvoice_Click
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "rInvoice"
stLinkCriteria = "((tProject.projID)=" & Me![projID] & ") AND ((" &
_
"[tTimeStamp].[timeStart]) BETWEEN #" & _
Me![dateStart] & "# AND #" & Me![dateEnd] & "#)"
DoCmd.OpenReport stDocName, acPreview, "qViewInvoice",
stLinkCriteria
..
..
..
When I use a MsgBox to show stLinkCriteria it looks fine:
((tProject.projID)=9) AND (([tTimeStamp].[timeStart]) BETWEEN
#01/01/2005# AND #01/02/2005#)
BUT suddenly an input box appears out of the blue (background theme)
asking for:
tTimeStamp.timeStart
As if it's a parameter query. Why? Why is it suddenly looking for
tTimeStamp.timeStart when the query, separately, doesn't seem to be too
concerned about tTimeStamp.timeStart? Where am I going wrong?
If anyone can just give a hint, I'd much appreciate it.
Cheers,
Henry Holland
Grahamstown
South Africa
I've been plodding my way through designing and implementing a database
that I need to organise my work, and I've been more successful than I
thought I'd be. That's the good bit. Now, however, I am completely
flumoxed (if that's the correct spelling), and I have been for a couple
of days now. This is the scene (bear in mind that this is my first
proper exposure to Access and databases in general):
I have a form with a button that calls up a report linked to a fairly
nasty looking query. The idea is that the button calls up an Invoice
(the report) which has to gather all the necessary information from the
database using a query. The form works, the report works and the query
works. But they don't work together. I'm using Access2002.
The query looks like this (appologies for the length/size but I'm
posting it since I suspect it may be the query that's the problem):
SELECT
tProject.projID, First(tProject.title) AS Project,
First(tProject.clientRefNum) AS Reference, First(tDeliverable.name) AS
Deliverable, First(tProcess.name) AS Process, Avg(tProcess.rates) AS
Rates, Sum(DateDiff("n",tTimeStamp.timeStart,tTimeStamp.timeStop)) AS
Minutes,
Round(Sum(DateDiff("n",tTimeStamp.timeStart,tTimeStamp.timeStop))/60)
AS Hours,
(Round(Sum(DateDiff("n",tTimeStamp.timeStart,tTimeStamp.timeStop))/60))*First(tProcess.rates)
AS Cost, First(tClients.CompanyName) AS Company,
First(tClients.VatNumber) AS [VAT Number], First(tContacts.firstName) &
" " & First(tContacts.lastName) AS [Contact Name],
First(tAddresses.Address) AS Address, First(tAddresses.City) AS City,
First(tAddresses.PostalCode) AS [Postal Code],
First(tAddresses.Province) AS Province, First(tAddresses.Phone) AS
Phone, First(tAddresses.FaxNumber) AS Fax, Min(tTimeStamp.timeStart) AS
MinOftimeStart
FROM
(tContacts INNER JOIN ((tClients INNER JOIN (tAddresses INNER JOIN
txAddressClient ON tAddresses.AddressID=txAddressClient.addressID) ON
tClients.clientID=txAddressClient.clientID) INNER JOIN tProject ON
tClients.clientID=tProject.clientID) ON
tContacts.contactID=tProject.contactPrimary) INNER JOIN ((tDeliverable
INNER JOIN tProcess ON tDeliverable.delivID=tProcess.delivID) INNER
JOIN tTimeStamp ON tProcess.processID=tTimeStamp.procID) ON
tProject.projID=tDeliverable.projID
GROUP BY tProject.projID, tProcess.processID, tDeliverable.delivID;
The query works. When I add parameters for the period for which I want
to display the invoice, it still works and produces the desired
results. Here's the WHERE clause I added to test:
WHERE tTimeStamp.timeStart BETWEEN [Start of period:] AND [End of
period:]
The report (rInvoice) works perfectly (only quite perfectly, I fear)
with this query (with or without the WHERE clause).
In the form, using the query without the WHERE clause above, I call the
report with the following (what I presume to be standard) code:
Private Sub btnViewInvoice_Click()
On Error GoTo Err_btnViewInvoice_Click
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "rInvoice"
stLinkCriteria = "((tProject.projID)=" & Me![projID] & ") AND ((" &
_
"[tTimeStamp].[timeStart]) BETWEEN #" & _
Me![dateStart] & "# AND #" & Me![dateEnd] & "#)"
DoCmd.OpenReport stDocName, acPreview, "qViewInvoice",
stLinkCriteria
..
..
..
When I use a MsgBox to show stLinkCriteria it looks fine:
((tProject.projID)=9) AND (([tTimeStamp].[timeStart]) BETWEEN
#01/01/2005# AND #01/02/2005#)
BUT suddenly an input box appears out of the blue (background theme)
asking for:
tTimeStamp.timeStart
As if it's a parameter query. Why? Why is it suddenly looking for
tTimeStamp.timeStart when the query, separately, doesn't seem to be too
concerned about tTimeStamp.timeStart? Where am I going wrong?
If anyone can just give a hint, I'd much appreciate it.
Cheers,
Henry Holland
Grahamstown
South Africa
.