?
Solved

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

Posted on 2010-01-07
10
Medium Priority
?
278 Views
Last Modified: 2013-11-28
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
0
Comment
Question by:cafulford
10 Comments
 
LVL 13

Expert Comment

by:ioane
ID: 26204393
Can't you just change your filter?

eg:
sBL_Filter = "DELIV_NUM='" & DELIV_NUM & "' AND PRINTED = False"
0
 

Author Comment

by:cafulford
ID: 26204462
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.
0
 
LVL 3

Assisted Solution

by:ClarkFilter
ClarkFilter earned 500 total points
ID: 26204487
I am assuming that the list box is called lstSelectedTrailers.  I do not see in the code where that actually gets used, or where DELIV_NUM comes from.  Is there a copy of this database that can be attached, perhaps with just a few garbage records?  I may be able to work out a solution if I had a copy or could see more of the code.
0
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
LVL 13

Accepted Solution

by:
ioane earned 1000 total points
ID: 26204637
Ok, I'm with you now. Something like this should do it.

Apologies its a bit messy, but I'm sure you'll be able to tidy it up if you want. (I don't normally use instant if's.)

sBL_Filter = "DELIV_NUM='" & DELIV_NUM & "' AND PRINTED = " & IIf(tglShowPrinted.Caption="Not Printed",False,True)
0
 

Author Comment

by:cafulford
ID: 26205126
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
0
 
LVL 13

Expert Comment

by:ioane
ID: 26205399
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.
0
 

Author Comment

by:cafulford
ID: 26210652
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
0
 
LVL 31

Assisted Solution

by:Helen Feddema
Helen Feddema earned 500 total points
ID: 26211953
How about an option group with buttons for Print All, Print Selected, and Print Unprinted)?  Then you could use a Select Case statement to deal with these 3 options.  (There would be one Print button running this code).  I agree with earlier experts that we need to see the database.  For fixing the Type Mismatch error, we need to know the data types of relevant fields.
0
 
LVL 13

Expert Comment

by:ioane
ID: 26278761
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.
0
 

Author Comment

by:cafulford
ID: 26283855
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
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Windows Explorer let you handle zip folders nearly as any other folder: Copy, move, change, and delete, etc. In VBA you can also handle normal files and folders, but zip folders takes a little more - and that you'll find here.
A Case Study of using the Windows API to provide RS232 communications capability in Access without the use of Active-X controls.
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Suggested Courses

599 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question