2 Replies - 5324 Views - Last Post: 01 May 2012 - 07:04 AM Rate Topic: -----

#1 seannb  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 30-April 12

Copying data from one table to another using a single combobox

Posted 30 April 2012 - 08:34 PM

A little background: I'm decent at programming in general, but have no real GUI experience, so I've decided to use MS Visual Studio 2010 and Visual Basic for my current project.

The project is this: I'm writing an app to print a list of beers that are currently on tap at the restaurant where I work part-time. We have 29 taps and dozens of different beers. I have 2 tables in a database (one with the "master list" of all the beers and an "on tap" one with one entry per tap). Each database entry includes fields for name, brewer, location, style and ABV. So far I've made a GUI with 29 combo boxes (one for each tap) and 2 buttons (one that opens a dialog box to modify the "master list" and one to print the list). The idea was to make it as simple as possible since the people who use it aren't great with computers and are often in a hurry.

Each combo box drops down the whole master list of beers and I'd like for the selected beer to be written to the corresponding index in the "on tap" table. My idea is to then extract the data from the "on tap" table and print it. I haven't done any coding yet, really, just drag-and-drop.

It's frustrating since I know how I'd do the back end in C or C++, but not in VB. The reverse is true for the GUI. Can anyone recommend a starting point? This seems like it should be so simple...

Attached image(s)

  • Attached Image
  • Attached Image


Is This A Good Question/Topic? 0
  • +

Replies To: Copying data from one table to another using a single combobox

#2 maj3091  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 299
  • View blog
  • Posts: 1,768
  • Joined: 26-March 09

Re: Copying data from one table to another using a single combobox

Posted 01 May 2012 - 12:01 AM

Welcome to the forum.

Couple of points/questions.

1. VS2010 is .Net, so technically, you're in the wrong forum with this, so you might want to ask a mod to move it for you.
2. If you're familiar with C and C++, why not opt for C# instead of VB (just curious)?
3. What is your database (Access, SQLServer, MySQL, other)?

If you look at the VB.Net forum, you should find a tutorial on DB usage in there, which would be a good starting point.
Was This Post Helpful? 0
  • +
  • -

#3 CharlieMay  Icon User is offline

  • This space intentionally left blank
  • member icon

Reputation: 1605
  • View blog
  • Posts: 5,162
  • Joined: 25-September 09

Re: Copying data from one table to another using a single combobox

Posted 01 May 2012 - 07:04 AM

As far as the beer being placed at it's corresponding index tells me that you would want to create a table with 29 rows and default them to -1 or something similar (I'm assuming here that you are storing the beer id in the list table).

Now when you save your selected beers from the Beer List Creator, you would perform an update and set the selectedValue of the comboboxes to that table.

For example, let's say you have 3 beers in your database
ID BeerName Etc...
1 Budweiser
2 Miller
3 Old Milwaukee

You would populate your comboboxes by binding them and use the DisplayMember and ValueMember to hold the BeerName and its Corresponding ID respectively.

So when you select a beer on Tab 1, it displays Miller but the valueMember holds 2

When you save this to your list table you already have all 29 rows so you update

UPDATE beerList SET (Tap1ID = The ValueMember of the Tap1 comobox, Tab2ID = The ValueMember of Tap2 etc...).
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1