By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,479 Members | 988 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,479 IT Pros & Developers. It's quick & easy.

Select Report to Print based on Form Entry

P: 78
I'm back with a new set of problems with the old NCR database from a year ago.

I have a form that is for Nonconformance Entry. In the process of entering this form if the supplier for the nonconforming material is external the entry person clicks a checkbox and a lookup is performed to a pass thru query.

Currently, we print off a Nonconformance report after all data is entered. We have added a new form for external vendors call a Defective Material Report. I need the print button to print off the Nonconformance Report if the external checkbox is not clicked and the Defective Material Report if it is clicked.
Dec 17 '07 #1
Share this Question
Share on Google+
6 Replies


Rabbit
Expert Mod 10K+
P: 12,382
Ok, so what's the problem?
Dec 17 '07 #2

P: 78
No problem... Was needing guidance on how to do something. Used the following to resolve the question:
Expand|Select|Wrap|Line Numbers
  1. Private Sub PrintReport_Click()
  2. On Error GoTo Err_PrintReport_Click
  3.  
  4.     Dim stDocName As String
  5. If Me![chkExternal] = True Then
  6.     stDocName = "DMR Form (All)"
  7. Else
  8.     stDocName = "NCR Form (All)"
  9. End If
  10.  
  11.     DoCmd.OpenReport stDocName, acPreview, , "[rptNumber]=[Forms]![FrmMasterEntry]![rptNumber]"
  12.  
  13. Exit_PrintReport_Click:
  14.     Exit Sub
  15.  
  16. Err_PrintReport_Click:
  17.     MsgBox Err.Description
  18.     Resume Exit_PrintReport_Click
  19.  
  20. End Sub
Dec 17 '07 #3

Rabbit
Expert Mod 10K+
P: 12,382
Good job!
Dec 17 '07 #4

P: 78
Thanks!

I now need to know how to make this work if a field in a query is true.

I am trying:

Expand|Select|Wrap|Line Numbers
  1. Private Sub Print_Debit_Memo_Click()
  2. On Error GoTo Err_Print_Debit_Memo_Click
  3.  
  4.         Dim stDocName As String
  5. If [Query]![qryDMRStart]![Scrap] = True Then
  6.     stDocName = "Debit Memo Scrap"
  7. Else
  8.     stDocName = "Debit Memo Rework"
  9. End If
  10.  
  11.     DoCmd.OpenReport stDocName, acPreview, , "[rptNumber]=[Forms]![FrmMasterEntry]![rptNumber]"
  12.  
  13. Exit_Print_Debit_Memo_Click:
  14.     Exit Sub
  15.  
  16. Err_Print_Debit_Memo_Click:
  17.     MsgBox Err.Description
  18.     Resume Exit_Print_Debit_Memo_Click
  19.  
  20. End Sub
But it doesn't work.....
Dec 21 '07 #5

jaxjagfan
Expert 100+
P: 254
Thanks!

I now need to know how to make this work if a field in a query is true.

I am trying:

Expand|Select|Wrap|Line Numbers
  1. Private Sub Print_Debit_Memo_Click()
  2. On Error GoTo Err_Print_Debit_Memo_Click
  3.  
  4.         Dim stDocName As String
  5. If [Query]![qryDMRStart]![Scrap] = True Then
  6.     stDocName = "Debit Memo Scrap"
  7. Else
  8.     stDocName = "Debit Memo Rework"
  9. End If
  10.  
  11.     DoCmd.OpenReport stDocName, acPreview, , "[rptNumber]=[Forms]![FrmMasterEntry]![rptNumber]"
  12.  
  13. Exit_Print_Debit_Memo_Click:
  14.     Exit Sub
  15.  
  16. Err_Print_Debit_Memo_Click:
  17.     MsgBox Err.Description
  18.     Resume Exit_Print_Debit_Memo_Click
  19.  
  20. End Sub
But it doesn't work.....
Use a DLookup to return the same value your query does or even return the value from the query itself. Otherwise looks pretty good.
Dec 21 '07 #6

Rabbit
Expert Mod 10K+
P: 12,382
Yeah, you'll have to do what jaxjagfan suggested. You can't use Query!QueryName!FieldName or Tables!TableName!FieldName. Those two formats only work with Reports and Forms.
Dec 21 '07 #7

Post your reply

Sign in to post your reply or Sign up for a free account.