Gurus: Conditional Printing (1 Viewer)

dyaron

New member
Local time
Today, 00:01
Joined
Jan 9, 2008
Messages
3
I have the following code:

DoCmd.OpenReport "010: NAME1 Field Check", acViewNormal, "", "", acNormal
DoCmd.OpenReport "020: NAME2 Field Check", acViewNormal, "", "", acNormal
DoCmd.OpenReport "030: NAME3 Field Check", acViewNormal, "", "", acNormal
DoCmd.OpenReport "040: NAME4 Field Check", acViewNormal, "", "", acNormal
DoCmd.OpenReport "050: HOUSE_NUMBER_1 Field Check", acViewNormal, "", "", acNormal
DoCmd.OpenReport "060: STREET Field Check", acViewNormal, "", "", acNormal
DoCmd.OpenReport "070: HOUSE_NUMBER_2 Field Check", acViewNormal, "", "", acNormal
DoCmd.OpenReport "080: PO Box Field Check", acViewNormal, "", "", acNormal
DoCmd.OpenReport "090: ORT01 (State/Region) Field Check", acViewNormal, "", "", acNormal
DoCmd.OpenReport "100: PSTLZ (Postal Code) Field Check", acViewNormal, "", "", acNormal
DoCmd.OpenReport "110: REGIO (State/Region) Abrv Field Check", acViewNormal, "", "", acNormal
DoCmd.OpenReport "120: LAND1 (Country Code) Field Check", acViewNormal, "", "", acNormal
DoCmd.OpenReport "130: CERDT (Certification WMDVBE Date) Field Check", acViewNormal, "", "", acNormal
DoCmd.OpenReport "140: STCD1 (Tax ID) Field Check", acViewNormal, "", "", acNormal
DoCmd.OpenReport "150: STCD2 (Tax ID 2) Field Check", acViewNormal, "", "", acNormal
DoCmd.OpenReport "160: STCD4 (Tax ID 4) Field Check", acViewNormal, "", "", acNormal
DoCmd.OpenReport "170: STMP_ADDR (Email) Field Check", acViewNormal, "", "", acNormal
DoCmd.OpenReport "180: FAX_NUMBER (Fax) Field Check", acViewNormal, "", "", acNormal
DoCmd.OpenReport "190: TEL_NUMBER1 (Telephone 1) Field Check", acViewNormal, "", "", acNormal
DoCmd.OpenReport "200: TEL_NUMBER2 (Telephone 2) Field Check", acViewNormal, "", "", acNormal
DoCmd.OpenReport "210: SUPPLIER_RELT_DISBLD_VET_FLAG (Disabled Vet) Field Check", acViewNormal, "", "", acNormal
DoCmd.OpenReport "220: SUPPLIER_MINORITY_CODE (Minority) Field Check", acViewNormal, "", "", acNormal
DoCmd.OpenReport "230: SUPPLIER_FEMALE_OWNED_CODE (Female) Field Check", acViewNormal, "", "", acNormal
DoCmd.OpenReport "240: ALTKN (Supplier Code) Field Check", acViewNormal, "", "", acNormal
DoCmd.OpenReport "250: FDGRV (Planning Group) Field Check", acViewNormal, "", "", acNormal
DoCmd.OpenReport "260: INCO1 (Shipping Terms) Field Check", acViewNormal, "", "", acNormal
DoCmd.OpenReport "270: CRA810_IRS_1099_CODE (1099) Field Check", acViewNormal, "", "", acNormal
DoCmd.OpenReport "280: CRA810_IRS_1099_HOLD_RATE (Hold Rate) Field Check", acViewNormal, "", "", acNormal
DoCmd.OpenReport "290: CRA810_FOREIGN_ENT_FLAG (Foreign Entity) Field Check", acViewNormal, "", "", acNormal
DoCmd.OpenReport "300: CRA810_FOREIGN_ENT_FLAG2 (Foreign Entity 2) Field Check", acViewNormal, "", "", acNormal
DoCmd.OpenReport "310: PHONE (Vendor Contact Number) Field Check", acViewNormal, "", "", acNormal
DoCmd.OpenReport "320: NAMEV (Vendor Contact Name) Field Check", acViewNormal, "", "", acNormal
DoCmd.OpenReport "330: KTOKK (Account Group) Field Check", acViewNormal, "", "", acNormal
DoCmd.OpenReport "340: OLD_APS_ID (APS ID) Field Check", acViewNormal, "", "", acNormal
DoCmd.OpenReport "350: DEFAULT_ID Field Check", acViewNormal, "", "", acNormal


But, on each report there is an unbound text box with a DCOUNT Formula. I want to be able to check the value of that text box first and decide to print or not. Psuedo code would be as follows:

For each report
if txtVerify>0 then
Print Report Command
else
Skip Report
Next Report
 

pono1

Registered User.
Local time
Today, 00:01
Joined
Jun 23, 2002
Messages
1,186
If you're trying to stop a report from printing when there are no records in the report, try working with the report's No Data event...roughly as follows:

Open the report in design mode and bring up the property dialog (F4). On the Event tab of the Report property dialog, there is an On No Data textbox...Click inside it and then click on the button with the three dots that appears at the right.

Select Code Builder from the dialog that pops up and click OK. You should be taken into the VBA environment. One line of code needed here...

Code:
Private Sub Report_NoData(Cancel As Integer)

' Don't do anything if there's no data.
  Cancel = True

End Sub

Regards,
Tim
 

Users who are viewing this thread

Top Bottom