473,326 Members | 2,173 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,326 software developers and data experts.

combo box linking to a textbox

hi, this is the code i have to put the text ina combo box thats being show
into a text box

Private Sub cmbteams_SelectedIndexChanged(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles cmbteams.SelectedIndexChanged

If cmbteams.SelectedIndex <> -1 Then
Me.TextBox1.Text = Me.cmbteams.SelectedItem
End If

End Sub

then, if i try to call it later from a different form to see what the text
is, all it shwos is "TextBox1", heres how i call it

Private Sub lblaa5_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles lblaa5.Click
Me.lblaa5.Text = team.TextBox1.Text
End Sub

lblaa5 is a label on one of my forms, its text is what i want to be the same
as the other form(team)'s textbox to be when i click on the label

thanks
Nov 21 '05 #1
6 1651
iwdu15

Try to set in top of your program or your in your options
Option Strict On it will warn you for the kind of errors you probably get
now.

With Option Strict Off, your program is in a kind of VB6 compatible state.

You will than see that moving the value of the Combobox (not linking) will
be
Textbox1.Text = Combobox1.SelectedItem.ToString

The other problem, you needs what kind of forms you use.
For that is needed that you tell how you show your form, which can be as a
child of your parentform, the owner. As a Mdiform or as a dialog
(showdialog) or a complete seperated form started in a module.

I hope this helps,

Cor

Nov 21 '05 #2
I use the .show command to show it, but i have it so its always on top, but i
did the code u showed me and put "option strict on" and it still didnt work,
it still shows "TextBox1"
Nov 21 '05 #3
iwdu15,

Can you show us the code that you used?

As well which you use to create that second form

Cor
Nov 21 '05 #4
sure, heres how i declare the second form:

Dim team As New pickateam

pickateam being the form with the textbox on it

heres how i open it:

Dim frm As New pickateam
frm.Show()

and the rest of the code i already showed but il post again
Private Sub cmbteams_SelectedIndexChanged(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles cmbteams.SelectedIndexChang
If cmbteams.SelectedIndex <> -1 Then
Me.TextBox1.Text = Me.cmbteams.SelectedItem.ToString
End If

End Sub

then to get the text from the textbox:

Private Sub lblaa1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles lblaa1.Click
Me.lblaa1.Text = team.TextBox1.Text
End Sub

Nov 21 '05 #5
iwdu15

It is strange that the code you show does not work.

To be sure I tested it again

\\\
Private Sub Form1_Load(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
Dim frm As New Form2
frm.Owner = Me
frm.Show()
End Sub
Private Sub ComboBox1_SelectedIndexChanged(ByVal _
sender As System.Object, ByVal e As System.EventArgs) _
Handles ComboBox1.SelectedIndexChanged
TextBox1.Text = ComboBox1.SelectedItem.ToString
End Sub
///
And then form2 as you want
\\\
Private Sub Button1_Click(ByVal sender _
As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
TextBox1.Text = DirectCast(Me.Owner, Form1).TextBox1.Text
End Sub
////

I hope this helps,

Cor

Nov 21 '05 #6
hi, i figured out the problem, i accidently declared the form as 2 different
names and used one to open it and the other to say what the textbox was...so
thanks anyway
Nov 21 '05 #7

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

Similar topics

8
by: Lyn | last post by:
Hi, Can anyone tell me how the initial value displayed in Combo Box is determined when a form is opened? I am loading the dropdown from one field ("CategoryName") of a table, with "ORDER BY ". ...
2
by: Jeff Mason | last post by:
I'm observing some strange behavior when I use a bound combo box in conjunction with the combo's anchor property. I define a form which contains just a textbox and a combo box. The text box is...
6
by: Ron L | last post by:
I have a dataset whose source is a SQL 2k stored procedure that I am trying to display in a datagrid. This datasource has 4 columns that I am interested in here, a text column and 3 value columns...
7
by: Hans Merkl | last post by:
Hi, Can anybody recommend a combo box control (textfield + dropdown list) for ASP.NET? I have looked at some products and it seems they all have some problems. I haven't yet found a combo box...
9
by: Edwinah63 | last post by:
Hi everyone, Please let there be someone out there who can help. I have two BOUND combo boxes on a continuous form, the second being dependent on the first. I have no problem getting the...
5
by: debbie | last post by:
I have three combo boxes on a subform. I have tried setting them up so that when the user clicks in the combo box the curser moves to the left. I have searched the posts and can find nothing that...
2
by: Wayne | last post by:
I have a combo box and a text box on a form. When I choose a value from the combo box, I want it to be added to the textbox. I'm able to do this by using the following code when I click the combo...
9
by: Marianne160 | last post by:
Hi, I know there are various answers to this problem available on the web but none of them seem to work for me. I am using Access 2003 to make a form to look up data from a table. I have so far...
2
by: banderson | last post by:
Hello, I have a data entry form for a table with information about buildings and am having a problem making a combo box do what I want. I would like to make the combo box show a list of unique bldg...
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: 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...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
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
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.