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

link between combo box and textbox

143 100+
Hi..
i have a problem here...
i have a master table called casemaster and in tht i have one combobox called courtId and its filling from the court table.. i need to make a textbox infront of tht and it has to fill the court name from the court table... whenever the user click on the courtid in tht dropdown of combobox tht name of the court automatically has to appear in tht textbox... how can i make a link between the combobox and the textbox... both of them has to be filled from my court table...
can anyone give me a code sample...
plz i need a help here and very urgent
thank u very much
Jan 20 '09 #1
15 6326
debasisdas
8,127 Expert 4TB
you need to pass the court_id from the combo to the db query dunamically and from that fetch the court name.
Jan 20 '09 #2
Frinavale
9,735 Expert Mod 8TB
You should implement a method that handles the ComboBox's Click Event.
The Click event occurs whenever the user clicks ComboBox.
From there you can determine which item has been selected, you can retrieve the court name from the database, and put the court name in the text box.
Jan 20 '09 #3
squrel
143 100+
thank u very much for ur help.. bt can u give me any code sample plz
i wil appricate tht
thank u in advance
Jan 21 '09 #4
squrel
143 100+
ok i m putting this code bt not working and my textbox is empty..
i dont knw if i m doing rit... when i debug the line which is bold it shows "" and in my textbos it comes 0 ..... where i have to change
can u help me here plz
thank u

Expand|Select|Wrap|Line Numbers
  1. Private Sub cmbCourtId_Click()
  2. txtCourtId.Text = GetCorrespodingField("Court", "Courtid", "courtid", cmbCourtId, False)
  3. Dim cn As String
  4.   If cmbCourtId.Text = true  Then
  5.     'the following line is bold
  6.     cn = Val("select courtname from court where courtid = cmbcourtid.text")'<-----bold line---
  7.     Text1.Text = cn
  8.   End If
  9. End Sub
Jan 21 '09 #5
debasisdas
8,127 Expert 4TB
i don't understand your code .

what does GetCorrespodingField do ?
Jan 21 '09 #6
squrel
143 100+
the GetCorrespodingField is filling the combobox from my court table to my master table... tht is not the problem the if loop is the problem... the line which is bold is coming zero... how can i get the value of courtname in tht line?
Jan 21 '09 #7
squrel
143 100+
can anyone check my code and tel me wht changes i have to make in tht line.... need help here
Jan 21 '09 #8
debasisdas
8,127 Expert 4TB
try this
Expand|Select|Wrap|Line Numbers
  1. rs.Open "select court_name from court where court_id = '" & combo1.text & "'", con, adOpenDynamic, adLockOptimistic 
  2.  
next populate the textbox from recordset.
Jan 21 '09 #9
squrel
143 100+
i dont think i need to open the rs here... its a simple combo box and textbox... i am changing my code to this bt rhe bold line is telling me "type mismatch"
can anyone tel me why?

Expand|Select|Wrap|Line Numbers
  1. Private Sub cmbCourtId_Click()
  2.  Dim Rs       As New ADODB.Recordset
  3. txtCourtId.Text = GetCorrespodingField("Court", "Courtid", "courtid", cmbCourtId, False)
  4. Dim cn As String
  5. If cmbCourtId.SelectedIndex <> -1 Then
  6. 'following line is bold
  7. cn = Str("select courtname  from court where courtid = " & cmbcourtid.text)
  8. Text1.Text = cn
  9. End If
  10. End Sub
Jan 22 '09 #10
debasisdas
8,127 Expert 4TB
how have you planned to fetch data from database without opening the recordset ?
Jan 22 '09 #11
squrel
143 100+
if i open the recordset also still i m getting error
i did wht u told me to do bt still the text is not showing in my textbox...
tht is my problem
i opend the recordset as u told me bt the textbox is empty
tel me how to get it in the textbox
Expand|Select|Wrap|Line Numbers
  1. If cmbCourtId.Text <> -1 Then
  2. Rs.Open ("select courtname from court where courtid = '" & cmbCourtId.Text & "'"), adOpenDynamic, adLockOptimistic
then after tht wht i have to do??? whtever i m doing it tels me type mismatch
Jan 22 '09 #12
QVeen72
1,445 Expert 1GB
Hi,

You need to specify Connection object here :

Rs.Open ("select courtname from court where courtid = '" & cmbCourtId.Text & "'"), Conn, adOpenDynamic, adLockOptimistic

Regards
Veena
Jan 22 '09 #13
squrel
143 100+
Hi Veena,
Ok i wil do tht bt then how can i get tht in my textbox?
i have combobox called cmbcourtid and by selecting the index from tht i want the particular courtname appear in my textbox called text1 automatically.. i open the connection bt then how i get tht in my textbox?
can u help me in tht... whtever i m trying is telling me type mismatch... coz its a string
conn i can not put its giving me error as variable not define.. i put Db its working.. and the line after tht when i want to assign tht to a variable to get the courtname on the textbox.. how should it should be??? is my line rit after the rs.open??? i dont knw how it should be?
can u help in tht? coz cn is a string
thank u

Expand|Select|Wrap|Line Numbers
  1. Private Sub cmbCourtId_Click()
  2. Dim Rs       As New ADODB.Recordset
  3. txtCourtId.Text = GetCorrespodingField("Court", "Courtid", "courtid", cmbCourtId, False)
  4. Dim cn As String
  5. If cmbCourtId.Text <> -1 Then
  6. If Rs.State = adStateOpen Then Rs.Close
  7. Rs.Open ("select courtname from court where courtid = '" & cmbCourtId.Text & "'"), Db, adOpenDynamic, adLockOptimistic
  8.  
  9. cn = Rs.Fields( ).Value
  10.  
  11. Text1.Text = cn
  12. Text1.Refresh
  13. End If
  14. End Sub
Jan 23 '09 #14
debasisdas
8,127 Expert 4TB
I think i am wasting my time with you.

you seem to lack the basic knowledge of database handling in VB.

better you go through the database related articles in the insight section of VIsual Basic for some sample code.
Jan 23 '09 #15
squrel
143 100+
i got the thing long time back..
and u didnt waste ur time wit me i did everything exactly u told me and got the answer
thanks for all ur help
Jan 23 '09 #16

Sign in to post your reply or Sign up for a free account.

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...
4
by: Swinky | last post by:
I am trying to make a combo box dependent on a text box. I cannot get the combo box to pull the related data from the text box. I have been all over this user group & have tried several versions...
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...
2
by: Ruthenfods Tellez | last post by:
I have an application in asp; in my form I have a combo and a textbox, the combo is fill in from a database query. I cannot do the following: when selecting an item from the combo, it should send...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.