Filter for Inactive Documents (1 Viewer)

theDBguy

I’m here to help
Staff member
Local time
Today, 02:50
Joined
Oct 29, 2018
Messages
21,467
It makes sense but I decided to simplify it a little and just add MACHTYPE to the search box that you helped me with. Keeping it simple until I can get a few more hours under my belt and understand a little better. Thanks again.
Hi. Sounds good enough. Good luck with your project.
 

glabbe

New member
Local time
Today, 05:50
Joined
Apr 7, 2020
Messages
18
Here's another one for you, Can I create a report that looks like the setupsheet form, picture attached, and open the form for editing or the report for printing from a couple buttons on my search form, picture attached?
 

Attachments

  • AccessForum5.jpg
    AccessForum5.jpg
    242.4 KB · Views: 78
  • AccessForum6.jpg
    AccessForum6.jpg
    164.7 KB · Views: 83

glabbe

New member
Local time
Today, 05:50
Joined
Apr 7, 2020
Messages
18
Here's one I really need help with. I have records in my proddtl table marked as inactive. I have a search with a checkbox labeled inactive. I have a useraccess table that sets permission to this checkbox and that's all working just fine. Users without access to inactive records cannot see those in the listbox. What I'd like to do is allow some users with higher level rights the ability to list, select and print those inactive records while others cannot.

The code I use to allow users to open inactive records is this:

Private Sub btnOpenSelected_Click()
If Globals.UserAccess("SetupSheet") = False Then
MsgBox ("You do not have Access!")
Else
DoCmd.OpenForm "SetupSheet", , , "[ID]=" & [SearchList]
End If
End Sub

I've tried my best to turn this into a DoCmd.Printout but I'm stuck on the criteria.

Or, should I build this into the Where Condition in the Print Macro I'm currently using? I tried shoehorninig an Active=Yes in there but can't get 'er done.
1588369267718.png
 

theDBguy

I’m here to help
Staff member
Local time
Today, 02:50
Joined
Oct 29, 2018
Messages
21,467
Here's one I really need help with. I have records in my proddtl table marked as inactive. I have a search with a checkbox labeled inactive. I have a useraccess table that sets permission to this checkbox and that's all working just fine. Users without access to inactive records cannot see those in the listbox. What I'd like to do is allow some users with higher level rights the ability to list, select and print those inactive records while others cannot.

The code I use to allow users to open inactive records is this:

Private Sub btnOpenSelected_Click()
If Globals.UserAccess("SetupSheet") = False Then
MsgBox ("You do not have Access!")
Else
DoCmd.OpenForm "SetupSheet", , , "[ID]=" & [SearchList]
End If
End Sub

I've tried my best to turn this into a DoCmd.Printout but I'm stuck on the criteria.

Or, should I build this into the Where Condition in the Print Macro I'm currently using? I tried shoehorninig an Active=Yes in there but can't get 'er done.
View attachment 81705
Hi. If you want something printed on paper, it's best to create a report for it. Then, you can use OpenReport anytime.
 

glabbe

New member
Local time
Today, 05:50
Joined
Apr 7, 2020
Messages
18
I have a report, swsetupsheet, the trouble is the Where Condition, how do I add in the additional criteria of only allowing records marked as active to print. Currently I have ="[ID]=" & [SearchList]. Also shown in the attachment.
 

theDBguy

I’m here to help
Staff member
Local time
Today, 02:50
Joined
Oct 29, 2018
Messages
21,467
I have a report, swsetupsheet, the trouble is the Where Condition, how do I add in the additional criteria of only allowing records marked as active to print. Currently I have ="[ID]=" & [SearchList]. Also shown in the attachment.
When you use VBA, does the WhereCondition get the correct value, if you step through the code?
 

glabbe

New member
Local time
Today, 05:50
Joined
Apr 7, 2020
Messages
18
If you mean does it open the correct record that I clicked on, yes. I've tried this as a test and the print preview pops up the correct ID in the preview format if the user has permission. Just need to know how to add the condition that the record Inactive=False.

Private Sub cmdPrint_Click()
If Globals.UserAccess("SetupSheet") = False Then
MsgBox ("You do not have Access!")
Else
Dim strCriteria As String
strCriteria = "[ID]=" & [SearchList]
DoCmd.OpenReport "swsetupsheet", View:=acViewPreview, WhereCondition:=strCriteria
End If
End Sub
 

theDBguy

I’m here to help
Staff member
Local time
Today, 02:50
Joined
Oct 29, 2018
Messages
21,467
If you mean does it open the correct record that I clicked on, yes. I've tried this as a test and the print preview pops up the correct ID in the preview format if the user has permission. Just need to know how to add the condition that the record Inactive=False.

Private Sub cmdPrint_Click()
If Globals.UserAccess("SetupSheet") = False Then
MsgBox ("You do not have Access!")
Else
Dim strCriteria As String
strCriteria = "[ID]=" & [SearchList]
DoCmd.OpenReport "swsetupsheet", View:=acViewPreview, WhereCondition:=strCriteria
End If
End Sub
Try using the AND operator. For example:

strCriteria="Inactive=False AND ID=" & [SearchList]

Hope that helps...
 

glabbe

New member
Local time
Today, 05:50
Joined
Apr 7, 2020
Messages
18
It seems to ignore the False.

Private Sub btnPrintSelected_Click()
If Globals.UserAccess("Print") = False Then
MsgBox ("You do not have Access!")
Else
Dim strCriteria As String
strCriteria = "Inactive=false AND [ID]=" & [SearchList]
DoCmd.OpenReport "swsetupsheet", View:=acViewNormal, WhereCondition:=strCriteria
End If
End Sub
 

theDBguy

I’m here to help
Staff member
Local time
Today, 02:50
Joined
Oct 29, 2018
Messages
21,467
It seems to ignore the False.

Private Sub btnPrintSelected_Click()
If Globals.UserAccess("Print") = False Then
MsgBox ("You do not have Access!")
Else
Dim strCriteria As String
strCriteria = "Inactive=false AND [ID]=" & [SearchList]
DoCmd.OpenReport "swsetupsheet", View:=acViewNormal, WhereCondition:=strCriteria
End If
End Sub
What is the data type of the Inactive column?
 

glabbe

New member
Local time
Today, 05:50
Joined
Apr 7, 2020
Messages
18
Yes/No. I also tried, using True/False, 1/0 and Yes/No.
 

glabbe

New member
Local time
Today, 05:50
Joined
Apr 7, 2020
Messages
18
Pulled out a lot of records but left enough behind to play with.

To reiterate, the idea is to have several levels of users:
those who cannot view inactive parts in the search
those who can include inactive parts but can only preview and print active parts
those who can include inactive parts, can preview both active and inactive parts but only print active parts
those who can include inactive, preview and print all
 

Attachments

  • DEMO.zip
    159.2 KB · Views: 89

Users who are viewing this thread

Top Bottom