Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to send a string to printer 1

Status
Not open for further replies.

helmpost

Technical User
Sep 13, 2005
10
GB
Folks,

As usual, I find myself challenged by something that seems simple but I cannot see a way forward.

On code behind forms I run vb and assemble a string as I step through a recordset. The string gives the user the final string in the form msgbox, stringname using Chr$ to provide a simple legible format. All fine. But then the user asks for a printed copy of the msgbox contents. Ah! What to do? I've tried sending the string to a dos file and to a database field. I've also tried to direct the string contents directly to the printer. I know that I should replace the msgbox with a form and work from there but even then I cannot see easily how to store the string contents in a field (or variable)so that a report can be assembled and printed. The msgbox could contain around a 100 characters ...but usually not so many.

Can anyone suggest a way forward? I would rather stick with the msgbox but do understand that's not good practice.

Thanks and regards, Brian

 
Could you put a textbox on your form (could be invisible) and use it to hold the string? Then when you click a button, a report opens. The textbox on the report would have a controlsource of =forms!frmNameofForm!txtboxnameOnTheForm.
 
Mike,

That's ideal! Thank you. Do I actually need to store the values in a table (they are transitory) or should I be able to refer straight from the form - =forms!frmNameofForm!controlname just gives me #name? in the report.

My code in the form frmresults1 includes:-

Me.ptimes = strmessage (correctly puts the str in a field)
DoCmd.OpenReport "pursuittimes", acViewPreview

My report Control Source is =Forms!frmresults1!ptimes

Regards, Brian
 
Mike,

Found the problem - was my referencing. Forgot to include the full reference to the form/subform/control name. Full marks for coming up with a nice simple solution.

Best Rgards, Brian
 
Brian,

I'm glad it helped! This forum has helped me, a relative newbie, enormously.

Regards,

Mike
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top