423,680 Members | 2,394 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 423,680 IT Pros & Developers. It's quick & easy.

Search for a record and print a report

P: 3
I am using the below code to retrieve the record from the database and then print a report based on entered details but due to some security in my company the Macro and Module are not allowed to be work in the situation so can you help me to find a solution which allow the code work fine for all users .

Expand|Select|Wrap|Line Numbers
  1.  
  2. Private Sub cmdAll_Click()
  3. Dim LSQL  As String
  4.  
  5. 'Clear criteria
  6. GCriteria = ""
  7.  
  8. 'Display all customers
  9. LSQL = "select * from Customers"
  10.  
  11. Form_frmCustomers.RecordSource = LSQL
  12. Form_frmCustomers.Caption = "Customers (All customers)"
  13.  
  14. MsgBox "All customers are now displayed."
  15.  
  16. End Sub
  17.  
  18. Private Sub cmdReport_Click()
  19. 'Open report
  20. DoCmd.OpenReport "rptCustomers", acViewPreview, , GCriteria
  21.  
  22. End Sub
  23. Private Sub cmdSearch_Click()
  24. DoCmd.OpenForm "frmSearch", , , , , acDialog
  25.  
  26. End Sub
  27. Private Sub Form_Open(Cancel As Integer)
  28. 'Clear criteria when form is first opened
  29. GCriteria = ""
  30.  
  31. End Sub
Aug 8 '17 #1

✓ answered by NeoPa

Hi Vivek. I'm not sure suggesting code is much help when the question is about how to allow the code even to run at all in his environment at work.

@Mahmoud.
Your question is about getting the code past the company security yet you don't include details of how that security is configured. Without that, we can't even tell which version of Access you're using. The security features changed with Access Vista (or 2007).

Modern database security is largely based on trusted folders but can still be configured to work with a trusted code-signing certificate. The latter can be created for free by following the steps found at Code Signing & Certificates.

Share this Question
Share on Google+
2 Replies


P: 2
Expand|Select|Wrap|Line Numbers
  1. Private Sub cmdAll_Click()
  2. Dim LSQL  As String
  3.  
  4. 'Clear criteria
  5. GCriteria = ""
  6.  
  7. 'Display all customers
  8. LSQL = "select * from Customers"
  9.  
  10. Form_frmCustomers.RecordSource = LSQL
  11. Form_frmCustomers.Caption = "Customers (All customers)"
  12.  
  13. MsgBox "All customers are now displayed."
  14.  
  15. End Sub
  16.  
  17. Private Sub cmdReport_Click()
  18. 'Open report
  19. DoCmd.OpenReport "rptCustomers", acViewPreview, , GCriteria
  20.  
  21. End Sub
  22. Private Sub cmdSearch_Click()
  23. DoCmd.OpenForm "frmSearch", , , , , acDialog
  24.  
  25. End Sub
  26. Private Sub Form_Open(Cancel As Integer)
  27. 'Clear criteria when form is first opened
  28. GCriteria = ""
  29.  
  30. End Sub
Aug 12 '17 #2

NeoPa
Expert Mod 15k+
P: 31,084
Hi Vivek. I'm not sure suggesting code is much help when the question is about how to allow the code even to run at all in his environment at work.

@Mahmoud.
Your question is about getting the code past the company security yet you don't include details of how that security is configured. Without that, we can't even tell which version of Access you're using. The security features changed with Access Vista (or 2007).

Modern database security is largely based on trusted folders but can still be configured to work with a trusted code-signing certificate. The latter can be created for free by following the steps found at Code Signing & Certificates.
Aug 12 '17 #3

Post your reply

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