D
Dan Johnson
I have a database that is still in 2.0. Is it possible to do conditional formatting in a report in Access 2.0 such that if the number of characters is 4, then return the characters as BOLD?
Dan said:I have a database that is still in 2.0. Is it possible to do conditional formatting in a report in Access 2.0 such that if the number of characters is 4, then return the characters as BOLD?
Marshall said:Just use the Format event to set the FontBold PropertyL
Me.textbox.FontBold = (Len(Me.textbox) = 4)
Marshall said:Please keep the correspondence in the newsgroups. A
response to a question is not an invitation to private
consulting services.
The code Doug and I posted must be in the Format event
**procedure** of the section containing the text box, not
the OnFormat property.
Dan said:Sorry about the goof. I hit the wrong command button in Outlook Express. I
don't use Express too often.
I tried your suggestion and received a compile error. I put the following
into the Detail Header's Code Builder:
Sub Detail1_Format (Cancel As Integer, FormatCount As Integer)
[Field24].FontBold = (Len([Field24]) = 4)
End Sub
Marshall Barton said:Dan said:Sorry about the goof. I hit the wrong command button in Outlook Express. I
don't use Express too often.
I tried your suggestion and received a compile error. I put the following
into the Detail Header's Code Builder:
Sub Detail1_Format (Cancel As Integer, FormatCount As Integer)
[Field24].FontBold = (Len([Field24]) = 4)
End Sub
It would help if you told us what the error message said.
All I can do with the information is guess that you either
misspelled the name of the text box or maybe Field1 is not
the text box. It's odd, are you sure the Detail section is
named Detail1??
Dan said:Ok, I verified that the Detail is actually Detail1 but I tried it both ways.
I also verified from the properties that Field24 is correct.
Field24 is:
=IIf([Length]=4,(Format([ItemTag] & " " & [ITEMIDENT],">")),(Format([Tag
Indent] & " " & [ItemIdent],">")))
Is it possible that there two formatting issues butting heads within the
report? I have tried several scenarios down to stripping the formatting of
the field such that Field24 is:
=[ItemTag] & " " & [ITEMIDENT]
with the formatting that you suggested. That returned the ItemTag ITEMIDENT
without the bold appearing for those of 4 characters.
To describe how I am inserting your suggestion:
With the Detail Header highlighted, I right clicked to bring up the
Properties, Build Event, Sorting & Grouping selection. I am choosing Build
Event then Code Builder and I then verify that it is for the Detail1
section. From the Code Builder, I inserted:
Sub Detail1_Format(Cancel As Integer, FormatCount As Integer)
[Field24].FontBold = (Len([Field24]) = 4) End Sub
after deleting what was already there. I then saved it, exited, and ran the
report.
The report asked for the appropriate information (in this report it prompts
for
what Building Code) and upon the execution of the report, There are four
error boxes, in succession that appear. The first three are simply "Compile
Error" then the fourth is "Compile Error in 'On Format' Expression. Each of
the errors requires me to answer "OK" then after the fourth error, it goes
back to the Design View of the report.
Marshall Barton said:Dan said:Ok, I verified that the Detail is actually Detail1 but I tried it both
ways.
I also verified from the properties that Field24 is correct.
Field24 is:
=IIf([Length]=4,(Format([ItemTag] & " " & [ITEMIDENT],">")),(Format([Tag
Indent] & " " & [ItemIdent],">")))
Is it possible that there two formatting issues butting heads within the
report? I have tried several scenarios down to stripping the formatting of
the field such that Field24 is:
=[ItemTag] & " " & [ITEMIDENT]
with the formatting that you suggested. That returned the ItemTag
ITEMIDENT
without the bold appearing for those of 4 characters.
To describe how I am inserting your suggestion:
With the Detail Header highlighted, I right clicked to bring up the
Properties, Build Event, Sorting & Grouping selection. I am choosing Build
Event then Code Builder and I then verify that it is for the Detail1
section. From the Code Builder, I inserted:
Sub Detail1_Format(Cancel As Integer, FormatCount As Integer)
[Field24].FontBold = (Len([Field24]) = 4) End Sub
after deleting what was already there. I then saved it, exited, and ran
the
report.
The report asked for the appropriate information (in this report it
prompts
for
what Building Code) and upon the execution of the report, There are four
error boxes, in succession that appear. The first three are simply
"Compile
Error" then the fourth is "Compile Error in 'On Format' Expression. Each
of
the errors requires me to answer "OK" then after the fourth error, it goes
back to the Design View of the report.
Sorry to take so long getting back to you. I didm't want to
trust 8 year old memories about how to use A2 so I dragged
my old Win3.11 machine out of mothballs (more moths than
mothballs). As far as I can tell, you did the right things,
at least up until you renoved what was already in the code
module. When you choose BuildEvent - Code Builder, Access
creates the event procedure skeleton:
Sub Detail1_Format( . . . )
End Sub
You should then Paste the line
[Field24].FontBold = (Len([Field24]) = 4)
in between those two lines.
The only reason I can see for a compile error is in your
post, you had the End Sub up on the tail end of the
assignment statement.
It is much easier to find compile errors, if you compile the
module yourself (instead of letting Access auto compile when
you preview the report. Use the Run - Compile Loaded
Modules menu item. You should also make sure that you have
Option Explicit
in the General - Declarations section of the module so any
undeclared or misspelled names generate an error.
You didn't provide any examples of your data so I can't
check what might be happening. Are you sure that the result
of the concatenation =[ItemTag] & " " & [ItemIdent] is only
4 characters? That would imply ItemTag and ItemIdent are
only 1 or 2 characters each.
I can't comment on where your longer IIf expression might be
going wrong, if it is wrong. When you have trouble with a
complex expression, I suggest you start with a simple
expression and build it up one component at a time until you
run into to a problem. For example,
=[Length]
=[ItemTag]
=[Tag Indent]
=[ItemIdent]
=[ItemTag] & " " & [ItemIdent]
=Format([ItemTag] & " " & [ItemIdent],">")
=[Tag Indent] & " " & [ItemIdent]
=Format([Tag Indent] & " " & [ItemIdent],">")
=IIf(True,Format([ItemTag] & " " &
[ItemIdent],">"),Format([Tag Indent] & " " &
[ItemIdent],">"))
=IIf(False,Format([ItemTag] & " " &
[ItemIdent],">"),Format([Tag Indent] & " " &
[ItemIdent],">"))
=IIf([Length]=4,Format([ItemTag] & " " &
[ItemIdent],">"),Format([Tag Indent] & " " &
[ItemIdent],">"))
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.