Want to print Value List results

VictorAtWork

Registered User.
Local time
Today, 16:39
Joined
Oct 16, 2015
Messages
10
I have pieced together a db that starts in a specific directory and lists all the folders. By double-clicking on a directory the value list displays the subdirectories.
I would like a Command button that will print all the values (subdirectories) in the current value list.

I am attaching the db for code viewing.
Any help would be appreciated.
 

Attachments

I have not had a chance to look at your attachment.

My first thought is to write the data to a table. This could be done easily at the same time the value list is being loaded. I would expect that to be much easier than writing VBA code to parse the value list.

Once in table it will be easy to print.

I have never tried to use a list box control on a report. That may work also. You would have to pass the value list from the form tot he report.
 
Victor, As already suggested, writing the value list data to a table would be the simplest approach.

As they say though, "there is more than one way to skin a cat". Attached is a database demonstrating another method.

Basically, the value list of your listbox is passed as openargs into a report. the string is trimmed and split into an array, and each value is printed into the report.

Although, i am not a fan of temporary tables, personally, i think i would go with HiTechCoach's suggestion.
 

Attachments

Thank you for your suggestions. I will review and let you know which way I go. Just as an insight - I have many people using this db to see if a link is already used in a website. Temp tables would be hard since it would have to erase the previous persons table to write a new temp table for someone else. There could be as many as 8 people attempting to see what link is already there and what link could be created.

Thanks again,
I will look into the report scenario and get back to everyone.
 
Pyro - I ran your suggestion and when I attempt to print I receive an error - Run-time Error 94: "Invalid use of Null". Debug says strDir_List = Me.OpenArgs is the error producer.
Any suggestions?
 
Nevermind - I found an answer. I added If Not IsNull(strDir_List) Then and now it works. Thank you all for your input! It is greatly appreciated and I will be resolving this thread.
 
Pyro- I resolved this a little to quickly.
When I try to print the report it allows me to pick my printer. When I click print I see the screen that says it is sending data, but no data arrives and no printout.
I also get an error 9: subscript out of range at
Else
Me.txtDir = strData(intPrintCounter)
in the Detail_Print Sub
 
The intPrintCounter value was not being reset. I have adjusted a few things - added basic error handling. See attached.
 

Attachments

Hi Pyro,

After attempting several times to have the report print, I changed the cmdReport_Click Sub on the Print List command button to:

<code>DoCmd.OpenReport "rptMain", acViewNormal, , , acWindowNormal, Me.ListFolders.RowSource </code>

I remembered that acViewPreview has problems with loops. It will display the results but doesn't send it to the printer because of the print queue. Now I am sending the data to the printer directly and not previewing it prior to printing and everything is working correctly.

Thank you again for your help.
 

Users who are viewing this thread

Back
Top Bottom