473,387 Members | 1,529 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Label Reference

Need some help with passing a label to a subroutine. I have a form with
lots of checkboxes. When the form loads i have a procedure that runs to
lookup values and check the appropriate boxes. If the box is checked I
want the label to look like a hyperlink. Then the user can click on the
label to open a new form that is linked to the checkbox. I had to make
labels that were not attached to the checkboxes. If you click a label
that is attached to a checkbox it toggles the value and I don't want
that. I have code that does this when the user first completes the form
and everything works fine. Now I want to populate the form when it
opens at a later time and that is where the trouble is.

When the FormLoad routine fires a dynamic routine runs to pull the
value for each box.
For Each ctl In Me.Controls
If ctl.ControlType = acCheckBox Then
. . .
This procedure then calls a subroutine that does the work. The problem
I'm having is passing the label to the subroutine. I have some naming
going on so I can use string functions to extract the label name from
the checkbox name. Since I'm doing this it doesn't recognize it as
label control. Does anyone know how I can do this dynamically so I
don't have to have 44 If statements or Case Select statements?

Thanks all
Mike

May 2 '06 #1
3 3807
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

I believe you're trying to do this:

If the CheckBox is named: "AccountOverDue"
and the associated label is named: "AccountOverDue_label"

then, you can do something like this to change the Label Caption:

Me(ctl.Name & "_label").Caption = "Click Me to get the Form"

The Me(ctl.Name & "_Label") gets translated to:

Me("AccountOverDue_label")

Which is the same as

Me!AccountOverDue_label

I don't believe you can change the format of a control to a Hyperlink
when in Form view. You probably have to be in Design view to do that.
I would suggest that you place a small CommandButton next to the
CheckBox and Enable/Disable it whenever the CheckBox is set to True
(checked).

Private Sub chkAccountOverDue_AfterUpdate()
' This routine will enable/disable the command button
' depending on the state of the checkbox (True = enabled).
Me!cmdAccountOverDue.Enabled = (Me!chkAccountOverDue = True)
End Sub

Then in the CommandButtons OnClick event procedure you'd open the
appropriate form.
--
MGFoster:::mgf00 <at> earthlink <decimal-point> net
Oakland, CA (USA)

-----BEGIN PGP SIGNATURE-----
Version: PGP for Personal Privacy 5.0
Charset: noconv

iQA/AwUBRFfogIechKqOuFEgEQLNGwCeKg33jWMGwWKfzi/eVXLLRixPkQ0AniTA
2EjO2bJy1CGD3Q61I54Rm+kq
=fxIY
-----END PGP SIGNATURE-----

Mike wrote:
Need some help with passing a label to a subroutine. I have a form with
lots of checkboxes. When the form loads i have a procedure that runs to
lookup values and check the appropriate boxes. If the box is checked I
want the label to look like a hyperlink. Then the user can click on the
label to open a new form that is linked to the checkbox. I had to make
labels that were not attached to the checkboxes. If you click a label
that is attached to a checkbox it toggles the value and I don't want
that. I have code that does this when the user first completes the form
and everything works fine. Now I want to populate the form when it
opens at a later time and that is where the trouble is.

When the FormLoad routine fires a dynamic routine runs to pull the
value for each box.
For Each ctl In Me.Controls
If ctl.ControlType = acCheckBox Then
. . .
This procedure then calls a subroutine that does the work. The problem
I'm having is passing the label to the subroutine. I have some naming
going on so I can use string functions to extract the label name from
the checkbox name. Since I'm doing this it doesn't recognize it as
label control. Does anyone know how I can do this dynamically so I
don't have to have 44 If statements or Case Select statements?

May 2 '06 #2
I'm not actually making the label a hyperlink just giving it a look of
a hyperlink. I'm changing the forecolor and fontunderline properties.
The problem is doing this dynamically. I can't pass the label name to a
subroutine by extracting the label name from the checkbox name.
So for example I have a checkbox named "AD_Prior5" then the label name
is "Prior5".
When the form loads I'm looping through the controls looking for
checked boxes. If they are checked I want to dynamically pass the
related label to a subroutine to set the property values. Here's the
string functions I'm using to get the label name:
Mid(ctl.Name, 4, Len(ctl.Name) - 3)

I tried assigning the result from above to a string variable then
assigning that variable to a label variable by: lbl = Me(test)
I get an error Object variable or With block variable not set.

May 3 '06 #3
MGFoster, your idea worked. I had to change where in the code I
referenced the label with the Me statement.
Had to it in the subroutine and not in the formload area.
Thanks

May 3 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: knoak | last post by:
Hi there, In my form, after validation, labels of wrong fields are turned into a red color. What i want now is when you hit 'reset', to make all the labels grey again. I have the next code:...
8
by: David McDivitt | last post by:
We have a massive java application to be made ADA compliant. We want onfocus and onblur events for each text field. The best way seems to be javascript, by cycling through all the nodes recursively...
7
by: Jon S via DotNetMonster.com | last post by:
Hi all, I posted this yesterday but didnt explain it too well so thought I would do it again. I have a label on a form that I want to be able to change the text while I'm in a seperate class...
6
by: Tom Kaminski [MVP] | last post by:
On my code behind page, how can I reference a Label control that's included in a Repeater? In other words, given: <asp:Repeater id="Repeater1" runat="server"> <HeaderTemplate> <table> <tr>...
1
by: clintonG | last post by:
I'm having a problem with a label in a MasterPage which is not in a ContentPlaceHolder. The naughty label will not allow me to change its text property. <%-- renders the label's text directly to...
12
by: vbnewbie | last post by:
I am having problems accessing properties of dynamically generated objects in VB2005. Can someone please help? In a nutshell: My app creates an equal number of checkboxes and labels that share the...
4
by: stevewy | last post by:
If I am using srcElement (or "target" for non-IE models) to return various properties of an object I have clicked on, can I access for "label for" value in any way? I'm thinking, for example, of...
2
by: Andy B | last post by:
I have the following listView control on a page: <asp:ListView ID="ListView1" runat="server" ItemPlaceholderID="PlaceHolder1"> <ItemTemplate> <dl> <dt>
7
by: troy_lee | last post by:
I have a sub with this code: Sub ColorLabel() Dim ctlCurrentControl As Control Dim lngYellow As Long lngYellow = RGB(255, 255, 0) Set ctlCurrentControl = Screen.ActiveControl With...
1
by: jmarcrum | last post by:
Hello! I have created a TemplateField inside my GridView and want to reference the Label which is in the first column of each row. I am getting an error everytime I debug?! Can anyone please...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.