Access 2.0 report

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?
 
D

Douglas J. Steele

There was no conditional formatting in Access 2.0 (it wasn't introduced
until Access 2000).

However, you should be able to add code to the detail section's along the
lines of:

Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
Me!MyTextBox.FontBold = (Len(Me!MyTextBox) = 4)
End Sub

--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


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?
 
M

Marshall Barton

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?


Just use the Format event to set the FontBold PropertyL

Me.textbox.FontBold = (Len(Me.textbox) = 4)
 
M

Marshall Barton

Marshall said:
Just use the Format event to set the FontBold PropertyL

Me.textbox.FontBold = (Len(Me.textbox) = 4)


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.
 
M

Marshall Barton

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.

Whoops, forgot to say that you get to the Format event
procedure by clicking the code builder button [ ... ] on the
right side of the OnFormat property.
 
D

Dan Johnson

I tried this in the Code Builder of the Detail Header section and received a
compile error when I ran the report. Was this where I should have done this?
The following is what I put in the builder:

Sub Detail1_Format(Cancel As Integer, FormatCount As Integer)
[Field24].FontBold = (Len([Field24]) = 4) End Sub
 
D

Dan Johnson

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

Any suggestions? Thanks for the patience.
 
M

Marshall Barton

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??
 
D

Dan Johnson

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.

Thanks, again, for the help.



--
Dan Johnson


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??
 
M

Marshall Barton

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],">"))
 
D

Dan Johnson

Duhhhh. I really feel inept. You provided the key for the final solution.
Here is what I did to do what I needed it to do:

Sub Detail1_Format (Cancel As Integer, FormatCount As Integer)
[Field24].FontBold = (Len([ItemTag]) = 4)

End Sub


I simply changed the second "[Field 24]" to "[ItemTag]". Your comments about
field length sparked me being able to see why the font didn't change.
Field24 will always be more than four characters BUT ItemTag won't.

Thank you so much for the help and especially for you patience in solving
this.

--
Dan Johnson


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],">"))
 

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

Top