473,386 Members | 1,766 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,386 software developers and data experts.

Solution: How to printout a richtextbox on an MS Access 2K form.

=============================
Problem:
=============================
How to printout a richtextbox on an MS Access 2K form.
=============================

=============================
Step by Step Solution:
=============================

1. Open a new form
2. Insert a Rich Text ActiveX and name it "RichText"
3. Insert a Common Dialog Box ActiveX and name it "CommonDialog1"
4. Save the new form and name it "TestForm"
5. Open the form code module for "TestForm" and insert the following
code.
===================================
Private Sub RichText_MouseDown(ByVal Button As Integer, ByVal Shift As
Integer, ByVal x As Long, ByVal Y As Long)
If Button = acRightButton Then
Call rtPrint
End If
End Sub

Public Function rtPrint()

'Use this code to print.

Dim saveSelStart As Long, saveSelLength As Long

On Error Resume Next
With CommonDialog1
.CancelError = True
.flags = cdlPDHidePrintToFile Or cdlPDNoPageNums Or
cdlPDReturnDC
If RichText.SelLength = 0 Then
' if no text is select, disable the option on the dialog
.flags = .flags Or cdlPDNoSelection
Else
' otherwise make "Selection" the default choice
.flags = .flags Or cdlPDSelection
End If
.ShowPrinter
If Err = 0 Then
If .flags And cdlPDSelection Then
' User decided to print the current selection,
RichText.SelPrint .hdc
Else
' User decided to print the entire contents, so select
it
saveSelStart = RichText.SelStart
saveSelLength = RichText.SelLength
RichText.SelStart = 0
RichText.SelLength = 999999
' Print on the device context returned by the common
dialog
RichText.SelPrint .hdc
' Restore old selection
RichText.SelStart = saveSelStart
RichText.SelLength = saveSelLength
End If
End If
End With
End Function
===================================
6. Close the form code module for "TestForm"
7. Close Design View and the open "TestForm"
8. Enter text into the Rich Text field on the form.
9. Right click to open print dialog
10. Click on OK to print.
11. Voila
Nov 12 '05 #1
0 1422

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: John Broderick | last post by:
I've got a problem with the RichTextBox control in .Net where the garbage collector doesn't reclaim its memory after I've finished with it. My program adds a series of rtb's to the control array...
1
by: P | last post by:
Hi, Access 2002. I am trying to use the PrintOut function to print the current record of the current open form in landscape format to the default Windows printer. Any suggestion on how to set...
0
by: Owen Jenkins | last post by:
I use the DoCmd.Printout method to print reports using the client's default options This has worked fine for years with Access 97 and 2000/2, Win95-XP. However two clients have recently complained...
0
by: PC User | last post by:
============================= Problem: ============================= How to printout a richtextbox on an MS Access 2K form. ============================= ============================= Step by...
2
by: Smartin | last post by:
Question about DoCmd.PrintOut in A97. I have a form on which all the controls are unbound. There is a large textbox that the user can type stuff in and a couple labels. I am trying to code a...
2
by: KenH | last post by:
I am getting an unhandled system exception while writing to a RichTextBox. The process may run for a few hours or days before the error is generated The message is "Cannot access a disposed object...
1
by: Nathan Carroll | last post by:
In an mdi environment I constructed a child for with a richtextbox control that is used to load .rtf's. This works fine on the intiatial load of the form but when for is closed and reopened later...
5
by: mthgk | last post by:
I have a C# MDI app. The child forms do alot of work, so this work is perfomed on a different thread created using ThreadPool.QueueUserWorkItem(). Because the status of the work is important to...
6
by: EJO | last post by:
TIA, There is already a form (Access 2k) with the selected record and a button with this code behind it: DoCmd.PrintOut acSelection Except that Access does not print the acSelection, it...
9
by: James Wong | last post by:
Hi, I use the RichTextBox in my program. It will use different language in this RichTextBox (chinese and english characters), and it set the "DualFont" and use different fonts. By the way, how...
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...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.