Office PC - Not Allowed to DL Rich Text Control Pgm

  • Thread starter jemedwards via AccessMonster.com
  • Start date
J

jemedwards via AccessMonster.com

Thanks to two responses to my first post at

http://www.accessmonster.com/Uwe/Fo...2-Concatenating-Fields-Showing-Different-Font


I received guidance on my situation (of which I didn't know was a popular
question) how to make part of a control bold and the other part normal.

I work at an agency that has our PCs locked down tight so I'm unable to
download or copy any programs/files onto the PC otherwise I would try and
work with Mr. Lebans Rich Text control that on his website.

So I copied the Lebans code from the Lady database into my database and
attempted to modify it to work with my database but I'm having problems with
it. I hope that it's ok that I've copied it here with a request for someone
to run the debugger and what my problem is. The debugger keeps giving me
different errors regarding "with", "end with" and "endif". I don't
understand the Visual Basic program so I don't understand about debugging.

I must add that I've just taught myself Access (using Access 2003) and I know
nothing about Visual Basic which works with this code.

In Mr. Lebans code I only changed the name of the two fields used in the
original code (assignment instead of firstname and agencyname instead of
lastname). I also changed the name of the concatenated label to
agencynameandassignment instead of tdlady. Additionally I tried to remove
the margins from the original code because I do not need a box drawn around
the concatenated field.

Thank you for any assistance in helping me with my first little database.


=============================================================
Option Compare Database
Option Explicit


' **START CODE
' Written by Stephen Lebans 1999
' (e-mail address removed)
' www.lebans.com

' This sample database is for a Poster named "Lady".
' She wanted to print her concatenated Control with
' one part in Bold and the rest normal.

Private Sub Detail_Print(Cancel As Integer, PrintCount As Integer)

Const TWIPS = 1
Dim strassignment As String
Dim stragencyname As String
Dim intPosition As Integer
Dim CtlDetail As Control
Dim intMargin As Integer

' I'll leave in Italic and Color
' in case you want to use these
Dim oldFontBold As Integer
Dim oldFontItalic As Integer
Dim oldForeColor As Long
Dim oldFontName As String
Dim oldfontsize As Integer
Dim oldScaleMode As Integer

'Save current Font settings
With Me
oldFontItalic = .FontItalic
oldFontBold = .FontBold
oldForeColor = .ForeColor
oldFontName = .FontName
oldfontsize = .FontSize

oldScaleMode = .ScaleMode
'End With

' Set Margin for Border we will draw
' around your concatenated control.
'intMargin = 60

' Remember for this sample I am
' naming your control agencynameandassignment. You MUST
' change the name here to match that of the actual control. Also
' I assumed the control source is exactly as you posted to the NG
' =[agencyname]&" "&[assignment]
' OK lets find your control and seperate
' the concatenated field.
' for each control in details control
For Each CtlDetail In Me.Section(acDetail).Controls
If CtlDetail.agencyname = "agencynameandassignment" Then
With CtlDetail
.Visible = False
intPosition = InStr(1, .Value, ",")
stragencyname = Left(.Value, intPosition - 1)
strassignment = Mid(.Value, intPosition + 2)
'Debug.Print stragencyname
'Debug.Print strassignment

End With

With Me
' Make sure we are in Twips
.ScaleMode = TWIPS

' Grab Controls current Font settings
.FontName = CtlDetail.FontName
.FontSize = CtlDetail.FontSize

' Create desired Font settings
' for the agencyname - Bold Text
.FontBold = True
'.FontItalic = True
'.ForeColor = RGB(255, 0, 0) 'RED
.CurrentX = CtlDetail.Left
.CurrentY = CtlDetail.Top
' For some reason must be Me.Print not .Print
Me.Print stragencyname;
Me.Print ", ";

' Reset Font-> NO Bold for assignment
.FontBold = False
'.FontItalic = False
Me.Print strassignment


' Restore Reports original Font settings
..ScaleMode = oldScaleMode
..FontBold = oldFontBold
..FontItalic = oldFontItalic
..FontName = oldFontName
..FontSize = oldfontsize
..ForeColor = oldForeColor

End With

With CtlDetail
'While we are here lets draw a box around each field
'Me.Line ((.Left - intMargin), (.Top - intMargin))-Step((.Width +
(intMargin * 2)), (.Height + (intMargin * 2))), 0, B
End With
End If
Next

' Cleanup
Set CtlDetail = Nothing
End Sub
 
R

RoyVidar

jemedwards via AccessMonster.com wrote in message
Thanks to two responses to my first post at

http://www.accessmonster.com/Uwe/Fo...2-Concatenating-Fields-Showing-Different-Font


I received guidance on my situation (of which I didn't know was a popular
question) how to make part of a control bold and the other part normal.

I work at an agency that has our PCs locked down tight so I'm unable to
download or copy any programs/files onto the PC otherwise I would try and
work with Mr. Lebans Rich Text control that on his website.

So I copied the Lebans code from the Lady database into my database and
attempted to modify it to work with my database but I'm having problems with
it. I hope that it's ok that I've copied it here with a request for someone
to run the debugger and what my problem is. The debugger keeps giving me
different errors regarding "with", "end with" and "endif". I don't
understand the Visual Basic program so I don't understand about debugging.

I must add that I've just taught myself Access (using Access 2003) and I know
nothing about Visual Basic which works with this code.

In Mr. Lebans code I only changed the name of the two fields used in the
original code (assignment instead of firstname and agencyname instead of
lastname). I also changed the name of the concatenated label to
agencynameandassignment instead of tdlady. Additionally I tried to remove
the margins from the original code because I do not need a box drawn around
the concatenated field.

Thank you for any assistance in helping me with my first little database.


=============================================================
Option Compare Database
Option Explicit


' **START CODE
' Written by Stephen Lebans 1999
' (e-mail address removed)
' www.lebans.com

' This sample database is for a Poster named "Lady".
' She wanted to print her concatenated Control with
' one part in Bold and the rest normal.

Private Sub Detail_Print(Cancel As Integer, PrintCount As Integer)

Const TWIPS = 1
Dim strassignment As String
Dim stragencyname As String
Dim intPosition As Integer
Dim CtlDetail As Control
Dim intMargin As Integer

' I'll leave in Italic and Color
' in case you want to use these
Dim oldFontBold As Integer
Dim oldFontItalic As Integer
Dim oldForeColor As Long
Dim oldFontName As String
Dim oldfontsize As Integer
Dim oldScaleMode As Integer

'Save current Font settings
With Me
oldFontItalic = .FontItalic
oldFontBold = .FontBold
oldForeColor = .ForeColor
oldFontName = .FontName
oldfontsize = .FontSize

oldScaleMode = .ScaleMode
'End With

' Set Margin for Border we will draw
' around your concatenated control.
'intMargin = 60

' Remember for this sample I am
' naming your control agencynameandassignment. You MUST
' change the name here to match that of the actual control. Also
' I assumed the control source is exactly as you posted to the NG
' =[agencyname]&" "&[assignment]
' OK lets find your control and seperate
' the concatenated field.
' for each control in details control
For Each CtlDetail In Me.Section(acDetail).Controls
If CtlDetail.agencyname = "agencynameandassignment" Then
With CtlDetail
.Visible = False
intPosition = InStr(1, .Value, ",")
stragencyname = Left(.Value, intPosition - 1)
strassignment = Mid(.Value, intPosition + 2)
'Debug.Print stragencyname
'Debug.Print strassignment

End With

With Me
' Make sure we are in Twips
.ScaleMode = TWIPS

' Grab Controls current Font settings
.FontName = CtlDetail.FontName
.FontSize = CtlDetail.FontSize

' Create desired Font settings
' for the agencyname - Bold Text
.FontBold = True
'.FontItalic = True
'.ForeColor = RGB(255, 0, 0) 'RED
.CurrentX = CtlDetail.Left
.CurrentY = CtlDetail.Top
' For some reason must be Me.Print not .Print
Me.Print stragencyname;
Me.Print ", ";

' Reset Font-> NO Bold for assignment
.FontBold = False
'.FontItalic = False
Me.Print strassignment


' Restore Reports original Font settings
.ScaleMode = oldScaleMode
.FontBold = oldFontBold
.FontItalic = oldFontItalic
.FontName = oldFontName
.FontSize = oldfontsize
.ForeColor = oldForeColor

End With

With CtlDetail
'While we are here lets draw a box around each field
'Me.Line ((.Left - intMargin), (.Top - intMargin))-Step((.Width +
(intMargin * 2)), (.Height + (intMargin * 2))), 0, B
End With
End If
Next

' Cleanup
Set CtlDetail = Nothing
End Sub


I think I'd start with uncommenting the End With in the first with
block (Save current Font settings part). I can't see anything else
through a quick glance (but same disclaimer as in the other
thread, I haven't really used this, just tested)

Then in the following section

' If CtlDetail.agencyname = "agencynameandassignment" Then
If CtlDetail.Name = "agencynameandassignment" Then
' You test the .Name property against the name of your
' text control
With CtlDetail
.Visible = False
' intPosition = InStr(1, .Value, ",")
intPosition = InStr(1, .Value, " ")
' it seems you are not concatenating with a comma, try
' testing for space in stead.
stragencyname = Left(.Value, intPosition - 1)
strassignment = Mid(.Value, intPosition + 2)
' you might have to tweak the numbers here (use 1 in
' stead of 2?)

and probably also
' Me.Print ", ";
Me.Print " ";

In stead of creating a new thread, you could have continued
the previous one, which would have kept the information in
the same thread
 
J

jemedwards via AccessMonster.com

Thank you very much. Your suggestions help put me and my co-worker on the
right track to where we needed to go with this. We've seen one page in the
print preview and it's showing bold and normal just as we needed however
we've run into an entirely different problem - overflow error on a memo
(assignment) field.

You're right that I should have kept the same thread. I'll remember to keep
the subjects together. Now since I have an entirely new problem with the
overflow error I'll start a new thread.

Thank you again for your patience and your time!
jemedwards via AccessMonster.com wrote in message
Thanks to two responses to my first post at
[quoted text clipped - 137 lines]
Set CtlDetail = Nothing
End Sub

I think I'd start with uncommenting the End With in the first with
block (Save current Font settings part). I can't see anything else
through a quick glance (but same disclaimer as in the other
thread, I haven't really used this, just tested)

Then in the following section

' If CtlDetail.agencyname = "agencynameandassignment" Then
If CtlDetail.Name = "agencynameandassignment" Then
' You test the .Name property against the name of your
' text control
With CtlDetail
.Visible = False
' intPosition = InStr(1, .Value, ",")
intPosition = InStr(1, .Value, " ")
' it seems you are not concatenating with a comma, try
' testing for space in stead.
stragencyname = Left(.Value, intPosition - 1)
strassignment = Mid(.Value, intPosition + 2)
' you might have to tweak the numbers here (use 1 in
' stead of 2?)

and probably also
' Me.Print ", ";
Me.Print " ";

In stead of creating a new thread, you could have continued
the previous one, which would have kept the information in
the same thread
 
J

jemedwards via AccessMonster.com

On second thought I believe I should continue the thread with my overflow
problem because it just started occurring once I got the rich text problem
fixed. So here goes:

The field called "assignment" is assigned a data type of "memo" because the
field has up to 450 characters.

I'm receiving an Overflow error message when I try to run the report. I've
searched with keywords "overflow data memo text" but I'm just finding a lot
of info on what to do about numeric data overflows.

Thanks for any additional info with this new problem.

Thank you very much. Your suggestions help put me and my co-worker on the
right track to where we needed to go with this. We've seen one page in the
print preview and it's showing bold and normal just as we needed however
we've run into an entirely different problem - overflow error on a memo
(assignment) field.

You're right that I should have kept the same thread. I'll remember to keep
the subjects together. Now since I have an entirely new problem with the
overflow error I'll start a new thread.

Thank you again for your patience and your time!
jemedwards via AccessMonster.com wrote in message
<[email protected]> :
[quoted text clipped - 33 lines]
the previous one, which would have kept the information in
the same thread
 
R

RoyVidar

jemedwards via AccessMonster.com wrote in message
On second thought I believe I should continue the thread with my overflow
problem because it just started occurring once I got the rich text problem
fixed. So here goes:

The field called "assignment" is assigned a data type of "memo" because the
field has up to 450 characters.

I'm receiving an Overflow error message when I try to run the report. I've
searched with keywords "overflow data memo text" but I'm just finding a lot
of info on what to do about numeric data overflows.

Thanks for any additional info with this new problem.
[snip]

Sorry, I don't know.

For someone to assist, it would perhaps help to know which line
produced the error?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top