Printing only selected records from a search query? (1 Viewer)

M Costumes

Member
Local time
Today, 03:51
Joined
Feb 9, 2021
Messages
73
I made an inventory/rental database and I'm now in the process of fully working in it and of course I'm finding bells & whistles I would like to add. It has a search function that works well--user enters in parameters via combo boxes and it returns all inventory items meeting those criteria. Right now, it opens all the results/records in a single report. I'd like to add an additional option (it would be a second button) where the user could choose to open the results in a form to view the records, and then select with a checkbox which records to print in a report. Is that possible?

I can use the same query to open the results in a form (just need to build the form and button), but from there, to select specific records and then only those records show in the report, I'm guessing I need to write another query based on that form? Thank you for your input!
 

theDBguy

I’m here to help
Staff member
Local time
Today, 03:51
Joined
Oct 29, 2018
Messages
15,592
Hi. If you plan to use a checkbox, that checkbox has to be in the table. You can then use a query for your report where you filter the data by that checkbox. However, you must also consider providing a way to reset the checkbox, so the user can make the next selections without being affected by any previous selections. This could also turn out to be one where you would use a local temporary table, if multiple users could be doing the search, making selections, and printing reports at the same time.
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 06:51
Joined
Feb 19, 2002
Messages
32,285
What would cause the users to chose records from this list and not print the whole thing? Should you add additional criteria so that the user gets just what he wants to print? Should you make this a DS subform and allow the user to use the built in filters and then use those filters as criteria to create the query for the report? theDBguy has mentioned the problems with using checkboxes in a multi-user environment. You really want to avoid temp tables if you can due to the bloat they cause. Relational databases are based on set theory and finding a way to make a set short of picking 2, 12, and 35 individually should be the goal. If there is no way to make a "set" in any other way than with checkboxes, then you do what you have to do and deal with the bloat.
 

CJ_London

Super Moderator
Staff member
Local time
Today, 11:51
Joined
Feb 19, 2013
Messages
13,109
an alternative can be found here - it doesn't use a checkbox, but uses conditional formatting to indicate selected rows


conditional formatting is based on the contents of the hidden control -

So you can pass a filter in your openreport parameters along the lines of

"ID IN (" & replace(hiddentextfield,"|",",") & "")"
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 06:51
Joined
Feb 19, 2002
Messages
32,285
That is pretty slick CJ but I would add a third button to remove the highlight.
 

CJ_London

Super Moderator
Staff member
Local time
Today, 11:51
Joined
Feb 19, 2013
Messages
13,109
to 'clear all/select all'? sound like a good idea. To deselect, you just click on the row again
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 06:51
Joined
Feb 19, 2002
Messages
32,285
I realize that clicking a row will deselect but if I've clicked a dozen and they are widely spaced, it is easier to have a way to just clear them all:)
 

Users who are viewing this thread

Top Bottom