467,077 Members | 980 Online
Bytes | Developer Community
Ask Question

Home New Posts Topics Members FAQ

Post your question to a community of 467,077 developers. It's quick & easy.

Print a string variable

I have a string variable that is presently being sent to a MessageBox.

I want to add a command button to the Form so I can send the string variable
directly to the printer.

Is there a simple way to do this.

Thanks

Jan 21 '08 #1
  • viewed: 5047
Share:
2 Replies
The easiest way to print the value of your string variable is to create
a report which will contain the value of your string variable and just
open the report programatically. The trick is to write the content of
the string to a table which would be the recordsource for the report.
Then open the report in ViewNormal mode. That will not bring up the
report it will just print the report. Say tbl1 is the recordsource
table for Report3 and only contains one field.

Private Sub cmdOpenReport3_Click()
DoCmd.RunSql "Insert Into tbl1 Select '" & str1 & "'"
DoCmd.OpenReport "Report3", acViewNormal, , , acWindowNormal
End Sub

Rich

*** Sent via Developersdex http://www.developersdex.com ***
Jan 22 '08 #2
On 22 Jan 2008 00:30:33 GMT, Rich P <rp*****@aol.comwrote:
>The easiest way to print the value of your string variable is to create
a report which will contain the value of your string variable and just
open the report programatically. The trick is to write the content of
the string to a table which would be the recordsource for the report.
Then open the report in ViewNormal mode. That will not bring up the
report it will just print the report. Say tbl1 is the recordsource
table for Report3 and only contains one field.

Private Sub cmdOpenReport3_Click()
DoCmd.RunSql "Insert Into tbl1 Select '" & str1 & "'"
DoCmd.OpenReport "Report3", acViewNormal, , , acWindowNormal
End Sub

Rich
Or you can write a simple function which returns the value of the string
variable and make this function the control source of a text box on the report.
No need for a table.
Wayne Gillespie
Gosford NSW Australia
Jan 22 '08 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by MatrixCrawler | last post: by
3 posts views Thread by jitender001001@gmail.com | last post: by
2 posts views Thread by Looch | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.