Code to change label on No Data

N

Noel

Hi, Can anyone supply code for this please? I have a
report with a text box showing a pair number (the field
is text, not number, if that matters). Normally the text
box shows a number and its label says Pair. I want this
label to change to Unpaired if no pair number has been
allocated. My text box properties are:

Name: Placements.Pair
Control Source: Placements.Pair
Label: Label79
Caption: Pair

(I now realise that to have a Textbox Name and Control
Source with the same contents can confuse Access, so I
may have to change these to get the code to work - I did
in another case recently). Thanks in advance, Noel
 
J

Jeff Boyce

Noel

(A couple suggestions, both related to use of naming conventions on
controls:
Change the textbox Name to something like "txtPair" -- leave the quotes out
Change the textbox's label's name to something like "lblPair" -- again,
without the quotes)

You want to change the caption of this textbox if the textbox is empty?

When formatting happens in the section in which this control is placed
(OnFormat event), you can test for something in the textbox and set the
label's Caption property accordingly. Something like (actual syntax may
vary):

If Nz(Me!txtPair,"") = "" Then
Me!lblPair.Caption = "Unpaired"
Else
Me!lblPair.Caption = "Paired"
End If

Or if the "paired" condition happens more often, you can turn the If/Else
around for a microsecond speedup.

Good luck

Jeff Boyce
<Access MVP>
 
N

Noel

Jeff, Just tried this and its spot on. Thanks for the
quick reply. By the by - two quick questions. How do you
MPVs keep a track of ongoing posts - surely you dont have
to remember each one youve replied to and go off
searching for them each day? (like I do when Ive posted
more than one). Second, are there any sites on the net
where I could read up on code like this. Ive cadged so
much of it from you MVPs that Im almost getting to
understand it! Thanks again, Noel
 
J

Jeff Boyce

Noel

Was that 2 'trick' questions or quick ones? <g>

I use Outlook Express (others swear AT it) and set a flag on those posts I
wish to follow. Sometimes this even includes posts I respond to...

Several sites have collections of code -- here's just a few:
http://www.mvps.org/access/
http://users.bigpond.net.au/abrowne1/tips.html
http://www.datastrat.com/
http://members.rogers.com/douglas.j.steele/AccessIndex.html
http://www.granite.ab.ca/accsmstr.htm

You can also try searching on Google.com under the MS Access group.

Good luck!

Jeff Boyce
<Access MVP>
 
N

Noel

Jeff. Im not clever enough to think up trick questions!
Thanks for the info. Cheers, Noel
 
D

Duane Hookom

Noel,
If you use Outlook Express to read and respond in NGs, you can press
[Ctrl]+H to view only threads that you have posted in.

One small point of clarification, there are lots of great contributors in
these groups that are not MVPs.
 
J

Jeff Boyce

THANKS, DUANE! I didn't know that shortcut! (there's quite a bit I'm
finding that I don't know...)

Jeff
 
D

Duane Hookom

Are you:
-up all night
-visiting someplace in Eastern US
-a very early riser
-*

You don't even have a grandson living with you that gets you up at 3:30 AM.
 
J

Jeff Boyce

Early to bed, and early to rise, and not feeling much like sleeping these
days...

Best holiday wishes!

Jeff
 
N

Noel

Hi folks. I thought this thread had stopped but something
made me look again. Thanks for the info Duane. Happy hols
to you an Jeff. Regards, Noel
 

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