Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Still printing when record is empty

Status
Not open for further replies.

Xiphiaz

Programmer
Dec 29, 2003
33
NL
Hi,

I have a little problem I cant fix, maybe one of you can help me.

I repair monitors and made a form to fill in the details of the monitor.
In a sub-form I fill in all the parts that I have used.

For all the parts that have a Serial number on them there will be a separate form printed when I leave the subform.(not all parts have a serial number)
-----------------------------------------
MonitorAndPart = "Not [Serial number] Is Null AND" & MonitorID
DoCmd.OpenReport stDocname2, acViewNormal, , MonitorAndPart
-----------------------------------------

"Not [Serial number] Is Null" is working perfect, so only parts with serial are printed.

But, when I havent use any parts at all and I leave the sub form then it will print a blanco form.

How can I prevent that?

Already MANY thanks!
Xiphias
 
Have a look at the NoData event procedure of the Report object.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
What is the field name of the monitor field?

[tt]MonitorAndPart = "Not [Serial number] Is Null AND MonitoreIDfield = " & MonitorID[/tt]

The where condition of the openreport method is just the same as a where condition from an ordinary SQL statement, without the word Where. Should the monitorid field be text, single quotes,

[tt]MonitorAndPart = "Not [Serial number] Is Null AND MonitoreIDfield = '" & MonitorID & "'"[/tt]

Roy-Vidar
 
You guys are quick [thumbsup]

The monitor ID isnt the problem I think.
But just now I also found something about the "No data" in the report.

They advise to put "Cancel = true" when there is no data

This works, but now I got an error box in the form that my report is canceled.
Is there a way to cancel in a "clean" way?
 
The monitor thingie is a problem, as how you've set it up, it will concatenate something strange into the sql, say monitorid = 45:

[tt]Not [Serial number] Is Null AND45[/tt]

which might give problems...

For the cancel thingie, here is one approach

[tt]on error resume next
DoCmd.OpenReport stDocname2, acViewNormal, , MonitorAndPart
if err.number = 2501 then
err.clear
end if
on error got0 <your errorhandler>[/tt]

Roy-Vidar
 
Sorry roy, my fault!
Here is it compleet:
--------------------
Dim stDocName As String
stLinkCriteria = "[RMA nr]=" & "'" & Me![RMA nr] & "'"

stDocName = "Repair"
stDocname2 = "NONCONFORMINGMATERIALFORM"


stLinkCriteria1 = "Not [Serial number] Is Null AND" & stLinkCriteria
DoCmd.OpenReport stDocname2, acViewNormal, , stLinkCriteria1
---------------------
(in the first thread I changed the names a bit to make it easier to read, just in case you were as N00bs like me ::))

 
And what is the problem now?

Anyway - you miss a space, so the concatenation will bomb (see my above reply) - place a space after and:

[tt]...Is Null AND " & stLinkCriteria[/tt]

Roy-Vidar
 
I tested your cancel solution and IT WORKS!

Thanks! [sunshine]

Xiphias
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top