Why Ucase is not working on my report?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello Everyone

I can't seem to get this code to work and I am wondering why? I am trying to
set the textbox values to all uppercase letters. Please expain. ?:-(

Dim ctl As Control
For Each ctl In Me.Controls
If ctl.ControlType = acLabel Then
ctl.Caption = Replace(ctl.Caption, "_", " ")
ctl.Caption = UCase(ctl.Caption)
ctl.FontSize = 10
ctl.FontItalic = False
End If
Next ctl

For Each ctl In Me.Controls
If ctl.ControlType = acTextBox Then
ctl.Value = UCase(ctl.Value)
End If
Next ctl


Thanks In Advance
 
Kw,

You are trying to make a change to the data. The query that the report
is based on is likely not updateable, but even if it is, data in reports
is not editable. You can try editing or updating the data in the tables
before it gets to the report stage, or you can set the Format property
of the textboxes on the report to >
 
Thanks Steve

Very insightful! However, I was not trying to make changes to the data, just
the format to Upper Case. I am new to programming and I may have been
overzealous in my attempt to code. Is there a way to code the format or do I
have to do this to individual textboxes.

Thanks in Advance
kw_uh97
 
Kw,

I would personally set the formatting of the individual textboxes in the
design of the form. It may be possible in code, you could give it a try
by modifying your original attempt to something like this...

For Each ctl In Me.Controls
If ctl.ControlType = acTextBox Then
ctl.Format = ">"
End If
Next ctl
 
Kw,

Just to clarify, the UCase function, even though the end result is to
change the appearance of the data, it is not applying formatting. It is
actually changing the data. "Fred" becomes "FRED". If you change the
formatting, what you see on yiour form or report is "FRED", but the data
itself, as stored in the table, remains as "Fred", it's just the display
that is affected. Hope that helps.
 
Back
Top