Link to home
Start Free TrialLog in
Avatar of cafulford
cafulfordFlag for United States of America

asked on

How do I pass a toggle/switch to validate what type opf records to print?

I have a project I am still working on that I got some outstanding help on from one of the Access guru's, GrahamMandeno.

I have an issue I am trying to resolve. Basically, I have a form that allows the user to print BOLs (bill of ladings). They select the carrier/trailers they want to print from a listbox. They make their selections and press the "Print Selected BOLs" button and all the orders for the selected carrier/trailer combinations print. That is all working great.

The problem comes in when I added a button that toggles the selections for them to choose from in the list box to display the carriers/trailers that were 1) printed and 2) not printed. The toggle and selection works fine as well as the printing until there happens to be 1 order on a carrier/trailer that has already been printed and 1 that has not been printed. The way it will work now is:

If you select 1 that is not printed to print, it still prints all the carriers/trailers regardless of if they have been printed or not. I see where the code is (in highlighted green).

So my question is: how do I get the module "modPrintOneBOL" to only print the selected carrier/trailers the way it does not but also take into consideration the printed/not printed toggle?
toggle-print-problem.jpg
Avatar of ioane
ioane
Flag of New Zealand image

Can't you just change your filter?

eg:
sBL_Filter = "DELIV_NUM='" & DELIV_NUM & "' AND PRINTED = False"
Avatar of cafulford

ASKER

I thought of that but wouldn't that mean I would need 2 print buttons, 1 for printed and 1 for not printed otherwise I would not know how the toggle is set. I am really new to this so I might be way off base.
SOLUTION
Avatar of ClarkFilter
ClarkFilter
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Tramtrak,

I tried that but got "Error #424, Object required" (see snapshot).

Any ideas?

ClarkFilter, it is part of a huge database that I inherited. If there is not an easier way, I will try to see if I can break it up to create a dummy sample database tomorrow.

All the help is very much appreciated!

Charlie
toggle-print-problem2.jpg
Where is your code stored?

ie. In the vba page of the form or a module?

If it is in a module, copy it into the form and run it from there.
Tramtrak,

I think I am really close. I moved the print code from a module to the form but it is giving me type mismatch errors. I have tried changing the end of the filter to:

,False,True)
,"False","True")
,0,1)
,"0","1")
,Yes,No)
,"Yes","No")

I then created a test query to see what would find the record and the exact query is shown in my screenshot that found the record still gave me the same error when it is in the code.

Very frustrating...can you help?

Thanks again!
query-issue.jpg
SOLUTION
Avatar of Helen Feddema
Helen Feddema
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Can you mock up an example database with your report and table/query and upload so I can see exactly what you are doing? Resolving the problem will be much quicker this way.
I was finally able to get it to work by moving to another part of the code in the form. It was the same code and I have no idea why it works there but it does not hurt to get lucky every now and then :o)

Thanks for all your help!

Charlie