Returning CheckBox Value

J

JamesJ

Can't seem to get this to work.
On a Split Form I set the Visible property of a label to No.
I need to check to see if a check box is checked (1) or not (0)
If is checked I want the label to be visible if not visible no.
The following code in the OnCurrent of the form doesn't seem to work:

If Me!DvdShortList.Value = 1 Then

Me!lblShortList.Visible = True
Else
Me!lblShortList.Visible = False

End If

Any help will be appreciated
James
 
P

PJFry

Try explicitly declaring your Else:

If Me!DvdShortList.Value = 1 Then

Me!lblShortList.Visible = True

ElseIf Me!DvdShortList.Value = 0 (or whatever value)

Me!lblShortList.Visible = False

End If
 
R

Rob Parker

Hi James,

A checkbox (unbound, or bound to a Yes/No field) has a value of -1 when
checked.

Also, you can do this with one line of code (and you don't need the .Value
for Me!DvdShortList, since it's the default property):
Me!lblShortList.Visible = Me!DvdShortList

HTH,

Rob
 
J

JamesJ

It isn't working. I even changed the value to -1 and that didn't work
The single line didn't work either.
This is code working fine on a Single form. I'm not sure if being a Split
Form
has anything to do with it.
 
R

Rob Parker

What exactly do you mean by "It isn't working", and what do you mean by a
"Split Form"? Does anything happen? Do you mean a continuous form, when
you say split form? If that's the case, and you want the label visibility
to be set for each record, you can't do it via that type of code in the
form's Current event, since every instance of the control in the continuous
form will have the same property as that of the current record - ie. they
will all be visible, or all be hidden. To set things to appear different in
each record of a continuous form, you need to use conditional formatting,
rather than code in the form's Current event. You can set the conditional
format for the label control to check the value of a field, and change the
appearance of the control as required.

Does this help? If not, please post more details to clarify.

Rob
 
J

JamesJ

This is a Split Form in Access 2007.
When I say it's not working I mean when I select a record in the datasheet
and the checkbox is checked the label does not become visible.
This same thing works fine in another form but the form is a Single Form.
The Label's Visible Property is set to Yes and the code for the form's
Current
of the form is:

If Me!DvdShortList.Value = 0 Then

Me!lblShortList.Visible = False
Else
Me!lblShortList.Visible = True

End If

Same exact code and situation with Split Form but it isn't working there.

James
 
R

Rob Parker

Hi James,

Sorry about the confusion. I don't use Access 2007, so I'm not familiar
with split forms. I've just done a quick search, and found out what they
are (a Form View and a Datasheet View of the data at the same time). All I
can assume is that selecting a record in the datsheet section does not cause
the Current event of the form section to fire - if it did, I'd expect your
code to work. You could check that the code is actually running by putting
a Debug.Print or MsgBox statement in it, and go from there. Otherwise,
hopefully someone familiar with A2007 can take over from here.

Rob
 
J

JamesJ

Thanks. I do have trouble at times conveying my message in this manner.
Anyway, I did find that the Current event is firing, my message box
popped up.

James
 

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