Visual Basic Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreVisual Basic Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old November 23rd, 2003, 05:16 PM
MrSmooth MrSmooth is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2003
Posts: 6 MrSmooth User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via AIM to MrSmooth Send a message via Yahoo to MrSmooth
Combo box from a data base

Is there a way to get multible combo boxs to read from a database
or something of the such. I have about 5 combo boxs on the same
form. I wanna be able to add something to the data base or whatever
works with combo boxs. So I can enter something in the database once instead of 5 different
times.

Reply With Quote
  #2  
Old November 24th, 2003, 02:19 PM
Fisherman's Avatar
Fisherman Fisherman is offline
Inherits Programmer.Slacker
Dev Shed Regular (2000 - 2499 posts)
 
Join Date: Aug 2003
Location: Between my Id and your Ego
Posts: 2,178 Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 1 Week 1 Day 9 h 56 m 45 sec
Reputation Power: 111
Send a message via ICQ to Fisherman Send a message via AIM to Fisherman
give me a little more info here.. what exactly would you like to accomplish?
__________________
Fisherman

"Any intelligent fool can make things bigger, more complex, and more violent. It takes a touch of genius -- and a lot of courage -- to move in the opposite direction." - A.Einstein

Reply With Quote
  #3  
Old November 24th, 2003, 04:05 PM
MrSmooth MrSmooth is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2003
Posts: 6 MrSmooth User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via AIM to MrSmooth Send a message via Yahoo to MrSmooth
OK I was planing on trying to do this step by step but I can tell you what I am really wanting. I am trying to make somethign for my dad to figure up prices on material. I have made a form and it kinda looks like this. Desrciption/Unit Price/Amount of Units/Total all. I am trying to make it where the description is a cmbobox. So when he selects from it that it will put that in the description area and the unit price in the unit price area. You can see an example here I am wanting all the combo boxs to call from the same place so I don't have to put it in like 50 times.

Reply With Quote
  #4  
Old November 24th, 2003, 05:50 PM
Fisherman's Avatar
Fisherman Fisherman is offline
Inherits Programmer.Slacker
Dev Shed Regular (2000 - 2499 posts)
 
Join Date: Aug 2003
Location: Between my Id and your Ego
Posts: 2,178 Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 1 Week 1 Day 9 h 56 m 45 sec
Reputation Power: 111
Send a message via ICQ to Fisherman Send a message via AIM to Fisherman
oh... gotcha. Is it necessary for him to be able to add text into the combo boxes? If not, then I would use a listbox, or make the combo so that it is not updateable... but now for your question. After you open your connection and your recordset (I'm guessing at the beginning of your app), load the combo with a loop that steps through the recordset and pull out your defining field. Then, in the click event of your combo box, use the fact that both your combo box and your recordset are zero-based arrays. To do this, do a move in your recordset based on the index of your combo. So

Code:
Private Sub cboYourCombo_Click()
    rsYourRecordset(cboYourCombo.Listindex,0)
    'I would use text boxes to hold any values not selectable or 
    '    self defining.
    txtBox1.text=rsYourRecordset(0)
    txtBox2.text=rsYourRecordset(1)
    txtBox3.text=rsYourRecordset(2)
End Sub

Reply With Quote
  #5  
Old November 24th, 2003, 06:01 PM
MrSmooth MrSmooth is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2003
Posts: 6 MrSmooth User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via AIM to MrSmooth Send a message via Yahoo to MrSmooth
Is there a way to give it a value. So that once the item that is in the combo box is selected the items unit price will be put in auto maticly.

Also, I would like to set it where I can use a add feature, because prices change sometimes. Also he may have new things come about. I create a small form I hope can be added it has a layout kinda like the one shown in the above link but with only one combo box for adding the description and unit price.

Reply With Quote
  #6  
Old November 24th, 2003, 06:09 PM
MrSmooth MrSmooth is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2003
Posts: 6 MrSmooth User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via AIM to MrSmooth Send a message via Yahoo to MrSmooth
If you would like to look at my code I can zip and email it. So you can tell more about what I am doing. Also I am very new so I am sure the code could be simplefied alot. Just let me know.

Reply With Quote
  #7  
Old November 24th, 2003, 06:32 PM
Fisherman's Avatar
Fisherman Fisherman is offline
Inherits Programmer.Slacker
Dev Shed Regular (2000 - 2499 posts)
 
Join Date: Aug 2003
Location: Between my Id and your Ego
Posts: 2,178 Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 1 Week 1 Day 9 h 56 m 45 sec
Reputation Power: 111
Send a message via ICQ to Fisherman Send a message via AIM to Fisherman
well, using the code I gave you before, you should be able to update the form's text boxes automatically whenever the new combo box item is selected. Also, I would use a separate form to update your database. It makes more sense logically, although you could simply use a module-level boolean, say (mblnDirty) and set it to True whenever one of the text_changed events occurs for the text boxes. You can also use another module-level boolean, maybe called mblnEditMode, to designate whether the user has elected to add a new item to the database. Here's how I would do it...

have a form with your combo, text boxes, and buttons labeled as "Add New", "Edit Existing", "Update Database", and whatever other functionality you want. When you click the "Add New" button, clear the text boxes and the combo text field, and enable the text boxes (set a boolean, maybe mblnAddMode=True) and disallow all buttons except "Update Database". Allow the user to input new data and do validation, finishing the new record by clicking "Update Database", then reintialize your list and refresh your screen. Then, when you click "Edit Existing", turn on another bln (maybe mblnEditMode), unlock the text boxes and allow the user to change the fields. Validate the data when the user clicks the "Update Database" button, post the data back to the database, and reintialize the list.

I don't know if all that made sense.. zip your code if you want to.. i'll be happy to look at it.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreVisual Basic Programming > Combo box from a data base


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway
Stay green...Green IT