473,385 Members | 1,445 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

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
2 5719
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: MatrixCrawler | last post by:
Hi there, i just wondered if it is possible to handle a string variable as a mathematical order. If the variable contains i.e. "2*100" PHP should calculate it, so that i'm able to assign the...
16
by: PK9 | last post by:
I have a string variable that holds the equivalent of a DateTime value. I pulled this datetime from the database and I want to strip off the time portion before displaying to the user. I am...
8
by: John | last post by:
How can I set a variable (Table_Select) equal to another string variable (Table_1)? Example: -------------------------------- Table_1 = "Winner" For i = 1 to 3 Table_Select = "Table_" & i...
4
by: JohnR | last post by:
Hi all, I'm finally sick and tired of manually generating get/set properties for each private variable in a class so I'm trying to create a macro to do it. I'm stuck because I can't figure out...
4
by: weirdstuff | last post by:
Hi. I have this simple code: =========================================== ->Database query here (.. some code) $row=mysql_fetch_array($res); (...)
0
by: shaikm | last post by:
Hi, I have problem passing variable in a FOR LOOP. Following is my code. Any help much appreciated. ZS -- Procedure teta has two parameters l and q , l is the feature table and q is the...
3
by: jitender001001 | last post by:
hi all i m new to python and i have a problem of printing python variable using os.system() in bash !/usr/bin/env python var = "/home/anonymous" os.system("echo $var) it is not working..
2
by: Looch | last post by:
All, I'm trying to output but I can only get (brackets for clarity) when using the code below. How can I "break" into the query variable in the InsertName method to add the name parameter to...
5
by: mabrynda | last post by:
Good morning everybody, I'm trying to use a string variable inside the DoCmd.Close statement. Despite many attempts this doesn't work. Does anybody have a solution for that? I have a form called...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.