473,320 Members | 1,881 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,320 software developers and data experts.

how to pass label captions to a textbox in another form?

Hello there,

I have tried all day but in vain....here is the problem:

Form1: there are 50 labels (so far, the number is subject to change), each
label caption is a fruit or a vegetable, for example, label1's caption is
apple, label2's caption is banana, label3 citron, etc.

Form2: one textbox txt0.

Action: double click label1, open Form2 and fill txt0 "apple",
double click label2, open Form2 and fill txt0 "banana",
double click label3, open Form2 and fill txt0 "citron" etc.

Is is possible, How to do it?

Thank you.

Paul from Slovakia


Nov 13 '05 #1
4 5764
On Thu, 23 Sep 2004 19:48:39 GMT, Paul T. Rong wrote:
Hello there,

I have tried all day but in vain....here is the problem:

Form1: there are 50 labels (so far, the number is subject to change), each
label caption is a fruit or a vegetable, for example, label1's caption is
apple, label2's caption is banana, label3 citron, etc.

Form2: one textbox txt0.

Action: double click label1, open Form2 and fill txt0 "apple",
double click label2, open Form2 and fill txt0 "banana",
double click label3, open Form2 and fill txt0 "citron" etc.

Is is possible, How to do it?

Thank you.

Paul from Slovakia


In the Double-click event of each of the labels on form1:
DoCmd.OpenForm "Form2"
forms!Form2!Text0 = Me![Labelx].Caption

where the x in Labelx is the label number double-clicked.

--
Fred
Please only reply to this newsgroup.
I do not reply to personal email.
Nov 13 '05 #2
Thank you, fred

but I would like to some other way. because there are 50 labels (and the
number is subject to change according to the user), I can not to make it
manually in your way 50 times or even more.

Is it possible to by vba

1. to select all labels
2. to write in their "double click" property something like "=labelclick"
3. to add something like:

Private Function labelclick()
dim labelcap as string

' what is needed here is a vba function to get back the value of the
caption of the label we just double clicked
Docmd.OpenForm "Form1"
Forms![Form1].txt0 = labelcap

End Function

this is what i thought, anybody can help?

many thanks,

Paul

Bratislava, Slovakia
"fredg" <fg******@example.invalid>
??????:14****************************@40tude.net.. .
On Thu, 23 Sep 2004 19:48:39 GMT, Paul T. Rong wrote:
Hello there,

I have tried all day but in vain....here is the problem:

Form1: there are 50 labels (so far, the number is subject to change), each label caption is a fruit or a vegetable, for example, label1's caption is apple, label2's caption is banana, label3 citron, etc.

Form2: one textbox txt0.

Action: double click label1, open Form2 and fill txt0 "apple",
double click label2, open Form2 and fill txt0 "banana",
double click label3, open Form2 and fill txt0 "citron" etc.

Is is possible, How to do it?

Thank you.

Paul from Slovakia


In the Double-click event of each of the labels on form1:
DoCmd.OpenForm "Form2"
forms!Form2!Text0 = Me![Labelx].Caption

where the x in Labelx is the label number double-clicked.

--
Fred
Please only reply to this newsgroup.
I do not reply to personal email.

Nov 13 '05 #3
rkc

"Paul T. Rong" <et***@hotmail.com> wrote in message
news:Tc*********************@news.chello.at...
Thank you, fred

but I would like to some other way. because there are 50 labels (and the
number is subject to change according to the user), I can not to make it
manually in your way 50 times or even more.

Is it possible to by vba

1. to select all labels
2. to write in their "double click" property something like "=labelclick"
3. to add something like:

Private Function labelclick()
dim labelcap as string


My favorite way to add function to multiple controls of the same type
is through a class using WithEvents.

<clsLabelCaption>
Option Compare Database
Option Explicit

Private WithEvents m_label As Access.Label
Private m_targetForm As String

Public Sub init(lbl As Access.Label, formName As String)
m_targetForm = formName
Set m_label = lbl
m_label.OnDblClick = "[Event Procedure]"
End Sub

Private Sub m_label_DblClick(Cancel As Integer)
DoCmd.OpenForm m_targetForm, acNormal, , , , , m_label.Caption
End Sub
</clsLabelCaption>

<calling form code>
Option Compare Database
Option Explicit

Dim colFruitLbls As VBA.Collection
Private lbc As clsLabelCaption
Private Sub Form_Load()
Set colFruitLbls = New VBA.Collection
Dim ctl As Access.Control
For Each ctl In Me.Controls
'use the tag property to identify which labels
'should have the behaviour
If ctl.ControlType = acLabel And _
ctl.Tag = "true" Then
Set lbc = New clsLabelCaption
lbc.init ctl, "target"
colFruitLbls.Add lbc
End If
Next

Set lbc = Nothing

End Sub

Private Sub Form_Unload(Cancel As Integer)
Set colFruitLbls = Nothing
</calling form code>

<target form code>
Option Compare Database
Option Explicit

Private Sub Form_Load()
Dim s As String
s = Me.OpenArgs & ""

Me.Text0.Value = s
End Sub

</target form code>


Nov 13 '05 #4

Thank you, rkc, it works, thank you very much.

Paul
"rkc" <rk*@yabba.dabba.do.rochester.rr.bomb> дÈëÏûÏ¢ÐÂÎÅ
:Ut********************@twister.nyroc.rr.com...

"Paul T. Rong" <et***@hotmail.com> wrote in message
news:Tc*********************@news.chello.at...
Thank you, fred

but I would like to some other way. because there are 50 labels (and the
number is subject to change according to the user), I can not to make it
manually in your way 50 times or even more.

Is it possible to by vba

1. to select all labels
2. to write in their "double click" property something like "=labelclick" 3. to add something like:

Private Function labelclick()
dim labelcap as string


My favorite way to add function to multiple controls of the same type
is through a class using WithEvents.

<clsLabelCaption>
Option Compare Database
Option Explicit

Private WithEvents m_label As Access.Label
Private m_targetForm As String

Public Sub init(lbl As Access.Label, formName As String)
m_targetForm = formName
Set m_label = lbl
m_label.OnDblClick = "[Event Procedure]"
End Sub

Private Sub m_label_DblClick(Cancel As Integer)
DoCmd.OpenForm m_targetForm, acNormal, , , , , m_label.Caption
End Sub
</clsLabelCaption>

<calling form code>
Option Compare Database
Option Explicit

Dim colFruitLbls As VBA.Collection
Private lbc As clsLabelCaption
Private Sub Form_Load()
Set colFruitLbls = New VBA.Collection
Dim ctl As Access.Control
For Each ctl In Me.Controls
'use the tag property to identify which labels
'should have the behaviour
If ctl.ControlType = acLabel And _
ctl.Tag = "true" Then
Set lbc = New clsLabelCaption
lbc.init ctl, "target"
colFruitLbls.Add lbc
End If
Next

Set lbc = Nothing

End Sub

Private Sub Form_Unload(Cancel As Integer)
Set colFruitLbls = Nothing
</calling form code>

<target form code>
Option Compare Database
Option Explicit

Private Sub Form_Load()
Dim s As String
s = Me.OpenArgs & ""

Me.Text0.Value = s
End Sub

</target form code>


Nov 13 '05 #5

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

Similar topics

5
by: WindAndWaves | last post by:
Hi Gurus I have a very simple question this time. I have a continuous form with a textbox (ID number) and a label. The label has a on_click event: msgbox me.id.value If I click on the...
6
by: Armando | last post by:
Hey gurus - Access 2000 - I have a form with a series of box controls forming a map of clickable areas, and I want each one to have a label. No problem, just put 'em on, right? But I also want...
7
by: Rab | last post by:
hi i need to programmatically change the caption of a label that is linked to another control (i.e. textbox, combobox). it's for a generic function where i only know the textbox/combobox name...
0
by: Tom | last post by:
Hi, I have this question below but still cannot fix it. http://communities.microsoft.com/newsgroups/previewFrame.as p? ICP=msdn&sLCID=us&sgroupURL=microsoft.public.dotnet.framewo...
1
by: Venki | last post by:
I have a textbox to enter an email address followed by a telephone textbox. The email has a regularexpressionvalidator and a requiredfieldvalidator. The ReqField works fine, but if I put in an...
2
by: tshad | last post by:
Is there another way to put labels on a page other than asp:label? I have been building a page where I use a label to display the calculated result of some imput. I do it using Javascript. But...
6
by: andrew.ames | last post by:
Hi I have a pretty basic windows application created in Visual Studio 2005 and VB.NET. I set my Form's font to Arial 8.25pt, so when i added a label and a button they automatically have a...
2
by: shapper | last post by:
Hello, I am styling the labels on a section of my page as follows: label {float: left; width: 6.5em;} Now I want to remove this styling from a label that has the class "Message". Mu...
5
by: Mr. X. | last post by:
Hello. In Visual Studio 2008, there is on the toolbox -login -login, which create a login form. On that form there is a LoginButton, which click on it is evented on the "default.aspx.vb"...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.