Link Label to List Box

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a form in which I have placed a list box, with two visible columns.
The two columns are labelled "fldSub-Factors" and "fldCode" (current values
are "A", "B", "C", ... "K"). Both contain alpha values only. They are based
on a table called "tblSub-Factors", which has a total of 11 rows.

I have two additional items on the form, which I would like to be able to
change dynamically, based on the selection in the list box. The value
selected in "Sub-Factors" should be combined with the word "Form" to create
the title for the form (a label).

The corresponding value in Code should determine what field is displayed on
the other item on the form, which is an entry on another table called
"JE_Results". The columns in JE_Results are headed "A", "B", "C"..., "K".

So, if I select the first row from tblSub-Factors (which is Code A, and has
a title in the fldSub-Factors, in this case "Knowledge"), then the form title
should read "Knowledge Form". And, the fillable filed on the form should
then populate the fldCode on tblJE_Results.

Is this do-able? If so, how? If possible, Iwould like to do this through
the filed property windows in the form, since I am not experienced as a
programmer.

Thanks

Don
 
Here is a way that might wotk. Unfortunatly it's going to take some code. In
the afterupdate event of the list box insert this code:

me.visual basic name of the text box.controlsource = me.visual basic name of
the list box

You'll need to make sure that the bound column of the list box is set to the
column number of fldcode. Also this code doesn't check for any errors, such
as a null value in the list box. I've never tried something like this so I'm
not sure excatly how it will work with saving data to the table.


In order to display the title you would need another unbound text box. It's
control souce should be:

=[Name of List Box].column(The column number that has fldSub-Factors) & "
Form"

Hope this works for you!
 
Thanks, Eric,

I think I've made rogress, but it looks like I'm not there yet.

A couple of points. First, when I use the properties window to make the
changes you suggest, it seems to automatically re-write the code. So,
=me.Form_Label1.ControlSource=me.SubFactors, becomes
=[me].[Form_Label1].[ControlSource]=[me].[SubFactors]

I have made the corresponding change in the fld.Form_Label1. However, when
I click on the entries in the list box, I get a message back, saying "The
object doesn't contain the automation object 'me'." I am lost what to do now.

Can you help?

Thanks

Don

Eric Sambell said:
Here is a way that might wotk. Unfortunatly it's going to take some code. In
the afterupdate event of the list box insert this code:

me.visual basic name of the text box.controlsource = me.visual basic name of
the list box

You'll need to make sure that the bound column of the list box is set to the
column number of fldcode. Also this code doesn't check for any errors, such
as a null value in the list box. I've never tried something like this so I'm
not sure excatly how it will work with saving data to the table.


In order to display the title you would need another unbound text box. It's
control souce should be:

=[Name of List Box].column(The column number that has fldSub-Factors) & "
Form"

Hope this works for you!

Donald Dudar said:
I have a form in which I have placed a list box, with two visible columns.
The two columns are labelled "fldSub-Factors" and "fldCode" (current values
are "A", "B", "C", ... "K"). Both contain alpha values only. They are based
on a table called "tblSub-Factors", which has a total of 11 rows.

I have two additional items on the form, which I would like to be able to
change dynamically, based on the selection in the list box. The value
selected in "Sub-Factors" should be combined with the word "Form" to create
the title for the form (a label).

The corresponding value in Code should determine what field is displayed on
the other item on the form, which is an entry on another table called
"JE_Results". The columns in JE_Results are headed "A", "B", "C"..., "K".

So, if I select the first row from tblSub-Factors (which is Code A, and has
a title in the fldSub-Factors, in this case "Knowledge"), then the form title
should read "Knowledge Form". And, the fillable filed on the form should
then populate the fldCode on tblJE_Results.

Is this do-able? If so, how? If possible, Iwould like to do this through
the filed property windows in the form, since I am not experienced as a
programmer.

Thanks

Don
 
Hey Donald,

Sorry I was a little vague there. In the afterupdate event property needs to
be set to [Event Procedure], then you need to insert that code into the
module. I'm not sure which version you're using, but there should be a button
beside the afterupdate property with a '...' If you seleect that it should
give you an option for creating a macro, expression or code. You want to add
code. This is where you insert that line. Also is form_label a label or a
text box? It needs to be a text box. If need be you can modify the format
properties so that it looks like a label, even though it's a text box.

Hope that helps,


Eric

Donald Dudar said:
Thanks, Eric,

I think I've made rogress, but it looks like I'm not there yet.

A couple of points. First, when I use the properties window to make the
changes you suggest, it seems to automatically re-write the code. So,
=me.Form_Label1.ControlSource=me.SubFactors, becomes
=[me].[Form_Label1].[ControlSource]=[me].[SubFactors]

I have made the corresponding change in the fld.Form_Label1. However, when
I click on the entries in the list box, I get a message back, saying "The
object doesn't contain the automation object 'me'." I am lost what to do now.

Can you help?

Thanks

Don

Eric Sambell said:
Here is a way that might wotk. Unfortunatly it's going to take some code. In
the afterupdate event of the list box insert this code:

me.visual basic name of the text box.controlsource = me.visual basic name of
the list box

You'll need to make sure that the bound column of the list box is set to the
column number of fldcode. Also this code doesn't check for any errors, such
as a null value in the list box. I've never tried something like this so I'm
not sure excatly how it will work with saving data to the table.


In order to display the title you would need another unbound text box. It's
control souce should be:

=[Name of List Box].column(The column number that has fldSub-Factors) & "
Form"

Hope this works for you!

Donald Dudar said:
I have a form in which I have placed a list box, with two visible columns.
The two columns are labelled "fldSub-Factors" and "fldCode" (current values
are "A", "B", "C", ... "K"). Both contain alpha values only. They are based
on a table called "tblSub-Factors", which has a total of 11 rows.

I have two additional items on the form, which I would like to be able to
change dynamically, based on the selection in the list box. The value
selected in "Sub-Factors" should be combined with the word "Form" to create
the title for the form (a label).

The corresponding value in Code should determine what field is displayed on
the other item on the form, which is an entry on another table called
"JE_Results". The columns in JE_Results are headed "A", "B", "C"..., "K".

So, if I select the first row from tblSub-Factors (which is Code A, and has
a title in the fldSub-Factors, in this case "Knowledge"), then the form title
should read "Knowledge Form". And, the fillable filed on the form should
then populate the fldCode on tblJE_Results.

Is this do-able? If so, how? If possible, Iwould like to do this through
the filed property windows in the form, since I am not experienced as a
programmer.

Thanks

Don
 
Eric Sambell said:
Hey Donald,

Sorry I was a little vague there. In the afterupdate event property needs to
be set to [Event Procedure], then you need to insert that code into the
module. I'm not sure which version you're using, but there should be a button
beside the afterupdate property with a '...' If you seleect that it should
give you an option for creating a macro, expression or code. You want to add
code. This is where you insert that line. Also is form_label a label or a
text box? It needs to be a text box. If need be you can modify the format
properties so that it looks like a label, even though it's a text box.

Hope that helps,


Eric

Donald Dudar said:
Thanks, Eric,

I think I've made rogress, but it looks like I'm not there yet.

A couple of points. First, when I use the properties window to make the
changes you suggest, it seems to automatically re-write the code. So,
=me.Form_Label1.ControlSource=me.SubFactors, becomes
=[me].[Form_Label1].[ControlSource]=[me].[SubFactors]

I have made the corresponding change in the fld.Form_Label1. However, when
I click on the entries in the list box, I get a message back, saying "The
object doesn't contain the automation object 'me'." I am lost what to do now.

Can you help?

Thanks

Don

Eric Sambell said:
Here is a way that might wotk. Unfortunatly it's going to take some code. In
the afterupdate event of the list box insert this code:

me.visual basic name of the text box.controlsource = me.visual basic name of
the list box

You'll need to make sure that the bound column of the list box is set to the
column number of fldcode. Also this code doesn't check for any errors, such
as a null value in the list box. I've never tried something like this so I'm
not sure excatly how it will work with saving data to the table.


In order to display the title you would need another unbound text box. It's
control souce should be:

=[Name of List Box].column(The column number that has fldSub-Factors) & "
Form"

Hope this works for you!

:

I have a form in which I have placed a list box, with two visible columns.
The two columns are labelled "fldSub-Factors" and "fldCode" (current values
are "A", "B", "C", ... "K"). Both contain alpha values only. They are based
on a table called "tblSub-Factors", which has a total of 11 rows.

I have two additional items on the form, which I would like to be able to
change dynamically, based on the selection in the list box. The value
selected in "Sub-Factors" should be combined with the word "Form" to create
the title for the form (a label).

The corresponding value in Code should determine what field is displayed on
the other item on the form, which is an entry on another table called
"JE_Results". The columns in JE_Results are headed "A", "B", "C"..., "K".

So, if I select the first row from tblSub-Factors (which is Code A, and has
a title in the fldSub-Factors, in this case "Knowledge"), then the form title
should read "Knowledge Form". And, the fillable filed on the form should
then populate the fldCode on tblJE_Results.

Is this do-able? If so, how? If possible, Iwould like to do this through
the filed property windows in the form, since I am not experienced as a
programmer.

Thanks

Don
 
Back
Top