How do I check the current value of check box not reffering it by

A

alekm

Hi,
let's say I'm writing a code and I'm in the middle of event procedure for
check box. How do I check the current value of check box not reffering it by
name? Is there any other way than reffering it by its name. I want same code
to apply to several check boxes so I don't want to names fixed in code.
Thanx

alekmil
 
M

Marshall Barton

That will work in most situations, but there is no guanantee
that the active screen object is the form with the check
box.

You would be better off if you can find a way to use the
FORM's ActiveControl property.

If your common code is in a standard module, then passing
the form object or name to the common routine would be
better.
 
A

alekm

How do I do passing objects and names?


Marshall Barton said:
That will work in most situations, but there is no guanantee
that the active screen object is the form with the check
box.

You would be better off if you can find a way to use the
FORM's ActiveControl property.

If your common code is in a standard module, then passing
the form object or name to the common routine would be
better.
--
Marsh
MVP [MS Access]

I get it:
Screen.ActiveControl.value

.
 
M

Marshall Barton

You can pass a form name in the function;s arguments:

Public Sub MySub(nm As String)
If Forms(nm).ActiveControl Then
'Checkbox is checked
Else
'Checkbox is not checked
End If
End Sub

Then call it with:
MySub Me.Name

Passing the form object would be like:

Public Sub MySub(frm As Form)
If frm.ActiveControl Then
'Checkbox is checked
Else
'Checkbox is not checked
End If
End Sub

Then call it with:
MySub Me
 

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