View Full Version : Computer is about to get smashed!!!


Sam Summers
05-08-2003, 05:36 PM
I have a report that is base on a query. I am attempting to print from a button on a form using the code:

stDocName = "ConformancyCertRpt"
DoCmd.OpenReport stDocName, acNormal

This report uses the following query:

SELECT Equipment.EquipmentID, Equipment.LocationID, Equipment.EquipRef, Equipment.ItemNo, Equipment.TestDate, Equipment.CertID, Equipment.Scrapped, Equipment.Lost, ConformancyCerts.CertNo, EquipLookup.EquipDescription, EquipLookup.ENNumber
FROM ConformancyCerts INNER JOIN (EquipLookup INNER JOIN Equipment ON EquipLookup.EquipRef = Equipment.EquipRef) ON ConformancyCerts.CertID = Equipment.CertID
WHERE (((Equipment.Scrapped)=False) AND ((Equipment.Lost)=False) AND ((ConformancyCerts.CertNo)=[Forms]![ViewbyConformancy]![CertNo].[Text]))
ORDER BY EquipLookup.EquipDescription;

Prior to all this, the original form is opened via a parameter form (FindConfAccess), using the code:

CertNumber.SetFocus
stDocName = "ViewbyConformancy"
DoCmd.OpenForm stDocName, , , stLinkCriteria

DoCmd.Close acForm, "FindConfAccess"

Even though I can open the query and see the data and also preview the report, when I print the report it prints only the headings but no data?

I am on the virge of battering my computer to death!!!!!!!!!!

Many thanks if you can save the computer from going to the scrapyard!!!!

bjackson
05-08-2003, 09:16 PM
is the query a stored query or a sql string that you build in code

if its in code then you would need to refer to the form control a little differently,if the certno is a number

WHERE (((Equipment.Scrapped)=False) AND ((Equipment.Lost)=False) AND ((ConformancyCerts.CertNo)=" & [Forms]![ViewbyConformancy]![CertNo].[Text]))

if its a text data
WHERE (((Equipment.Scrapped)=False) AND ((Equipment.Lost)=False) AND ((ConformancyCerts.CertNo)=" & """" & [Forms]![ViewbyConformancy]![CertNo].[Text] & """" ))

Rich
05-08-2003, 10:54 PM
Have you tried leaving "FindConfAccess" open while printing the report? It's almost certain that having closed it your parameters have disappeared

Sam Summers
05-09-2003, 01:34 PM
Thanks guys

I had a think and ended up using Rich's idea which worked.

So thanks very much

Pat Hartman
05-09-2003, 07:06 PM
You need to be extremely careful when using the .text property. The .text property of Access controls is NOT the same as the .text property of VB controls. Please refer to the help entry I posted at this link to avoid problems.

http://www.access-programmers.co.uk/forums/showthread.php?s=&threadid=40219&highlight=text+property

Sam Summers
05-09-2003, 09:46 PM
Thanks very much for the warning Pat.
I see what you mean.
There's always so many little things to watch out for or learn. I'll get there one day hopefully?