473,771 Members | 2,372 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Populated results from combobox to textbox ?

2 New Member
I'll start this hopefully simple and add code where needed or requested.

Im using a combobox that bound to a DataSet. The Dataset retreives it's values from SQL.

I can retreive the values fine. However only displaying (1) Column. Which is fine.

Here's where it gets complicated for me. The dataset has 2 other columns that get filled. I need the resulting columns to be sent to text boxes when I select a value from the combobox.

Basically:
Expand|Select|Wrap|Line Numbers
  1.  txtbox1.text = combobox.column(2).selectedvalue
  2.  txtbox2.text = combobox.column(3).selectedvalue
However. using the method of course doesnt work and that's what I need to figure out.
Jan 9 '09 #1
2 3370
dibblm
2 New Member
OK. For anyone looking for this in the future let me tell you how I went about this.

I filled the DataSet with Data From SQL. Bound a ComboBox to the DataSet.
Expand|Select|Wrap|Line Numbers
  1.  txtbox1.text = dataset.tables("table name here").Rows(cbox1.selectedindex).Item("Column name here")
  2.  
  3.  txtbox2.text = dataset.tables("table name here").Rows(cbox1.selectedindex).Item("Column name here")
  4.  

First issue I ran into was VB sending errors because the first column was yet to be populated so I had to set the index of cbox1 to 0
Expand|Select|Wrap|Line Numbers
  1.  cbox1.selectedindex = 0
Then for the selected index chage event
Expand|Select|Wrap|Line Numbers
  1. If cbox1.selectedindex = -1 then
  2.   cbox1.selectedindex = 0
  3. end if
  4.  
  5. txtbox1.text = dataset.tables("table name here").Rows(cbox1.selectedindex).Item("Column name here")
  6.  
  7. txtbox2.text = dataset.tables("table name here").Rows(cbox1.selectedindex).Item("Column name here")
  8.  
Thats all there was too it. being a novice I was actually trying to get the data from the Column instead of the Row. "STUPID. Yes.."

If anyone wants to modify and tell of any other way we can make this better I would appreciate it.
Jan 9 '09 #2
Xennex
7 New Member
Seems like you were able to solve your problem well.. I tend to favor using the "With" statement when I have long object strings since each '.' is basically telling an object traversal.. I would just change the following like so:

Expand|Select|Wrap|Line Numbers
  1. With dataset.tables("table name here").Rows(cbox1.selectedindex)
  2.    txtbox1.text = .Item("Column name here")
  3.    txtbox2.text = .Item("Column name here")
  4. End With
Jan 21 '09 #3

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

Similar topics

5
3082
by: Steve | last post by:
I have an unbound combobox in the form header of a continuous form. The selection in the combobox sets the where clause in a querydef which determines QryPFrmInventoryManagement. The following code is in the afterupdate event of the combobox: Me.RecordSource = "QryPFrmInventoryManagement" Me!ItemCount = Me.RecordsetClone.RecordCount & " Items" MsgBox Me.RecordsetClone.RecordCount & " Items"
8
12106
by: Zlatko Matiæ | last post by:
There is a form (single form) and a combobox. I want that current record of the form is adjusted according to selected value in the combobox. Cuurrent record should be the same as the value in the combobox. What is the solution? Thank you in advance.
5
1398
by: Susan Bricker | last post by:
Any idea why a combobox would not populate? When the form is opened, it is opened with DOCMD.OPENFORM with selection criteria to send only those records for a particular dog (dogregnbr). The query for the rowsource of the combobox works when run from the query design window. combobox: cboTrialDt (trial date) combobox control source: trialclassID (from tblDogTitles) form record source: tblDogTitles
2
1942
by: Greg Bradburn | last post by:
Greetings, I have a form with two comboboxes that I want to be populated with the same values from a table (i.e. both comboboxes have the same table/column as their datasource and display member). The selections made from these comboboses are to be saved in two different columns in another table. For example, the possible selections could be from the "Description"
3
6835
by: TT (Tom Tempelaere) | last post by:
Hay there, I'm writing my own DataGridComboBoxColumn because .NET 1.1 does not have one (I hope .NET 2.0 supplies one). I based it on this article: http://msdn.microsoft.com/msdnmag/issues/03/08/DataGrids/default.aspx I have a problem when there are two DataGrid's on one form, and when I switch focus from one grid to the other. To be more precise, when I'm editing a combo box column in one grid, and then click in the combo column of...
30
4604
by: dbuchanan | last post by:
ComboBox databindng Problem == How the ComboBox is setup and used: My comboBox is populated by a lookup table. The ValueMember is the lookup table's Id and the DisplayMember is the text from a corresponding field in the lookup table. In my data table we store the ID in what I will call the 'key' field. == Description of the desired operation:
1
3373
by: polocar | last post by:
Ciao a tutti, leggendo qua e là per il forum ho scoperto che non sono l'unico ad avere questo problema. Se si inserisce un controllo ComboBox in un form di C#, non è possibile impostare la sua altezza ad un valore diverso da 21. Forse, cambiando la dimensione del font, si potrebbe riuscire a cambiare anche l'impostazione dell'altezza... (MS farebbe comunque meglio ad introdurre per il ComboBox una proprietà AutoSize impostabile a "false"...
14
3256
by: pukhton | last post by:
I am having a problem with my Access database, since I am new to this, I have no idea what is goign on???? okay here is the problem. I have a database which has Meds tables, and has two fields. 1- Medication_Name 2-Concentration On the form I have a combo box for Medication_Name (it has all the medication names form the Medication_Name field), and textbox for Concentration. I want my User when they pick the specific medication, the...
2
7155
by: DesCF | last post by:
I have a textbox and a combobox on a toolstrip. The user enters either an ID in the textbox or selects a name from the combobox. When the user selects a name from the combobox the textbox is filled in automatically by setting its .Text property equal to the .SelectedValue of the combobox. When the user enters an ID in the textbox the combobox's .SelectedValue is set to the .Text value in the ID textbox. All works fine but it is ...
0
9454
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10103
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9911
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8934
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7460
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5354
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5482
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4007
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3609
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.