Database Management
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsDatabasesDatabase Management

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:
Be the architects of evolution and help create the mobile internet future. It’s your move---enter to win here!
  #1  
Old March 25th, 2008, 12:58 AM
Steve887 Steve887 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2006
Posts: 36 Steve887 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 h 54 m 6 sec
Reputation Power: 3
Insert a multiple selection into a table

I'm currently attempting to do something way over my head in Access 2003. The relevent tables are:

products
prodid (PK)
name
description
price

shopping_basket
basketid (PK)
custid
prodid

The listbox on the form runs from a query that gets just the id and name of each product from the product table. What I want is for the user to select one or more products from a listbox on a form and, along with the customer id, be inserted into the shopping basket table.

What I'm trying to do is concatenate the string so each selected product id is put into one row in the shopping basket table. Ie, if product id 1 and 3 are selected, the string 1,3 is inserted into the table.

One way I've thought to do this is to use a loop that put each selected product into a string, which is what is inserted into the table.

Or am I going completely the wrong way?

Reply With Quote
  #2  
Old March 25th, 2008, 03:51 AM
MrFujin's Avatar
MrFujin MrFujin is offline
Lord of the Dance
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Oct 2003
Posts: 1,210 MrFujin User rank is Major (30000 - 40000 Reputation Level)MrFujin User rank is Major (30000 - 40000 Reputation Level)MrFujin User rank is Major (30000 - 40000 Reputation Level)MrFujin User rank is Major (30000 - 40000 Reputation Level)MrFujin User rank is Major (30000 - 40000 Reputation Level)MrFujin User rank is Major (30000 - 40000 Reputation Level)MrFujin User rank is Major (30000 - 40000 Reputation Level)MrFujin User rank is Major (30000 - 40000 Reputation Level)MrFujin User rank is Major (30000 - 40000 Reputation Level)MrFujin User rank is Major (30000 - 40000 Reputation Level) 
Time spent in forums: 1 Month 5 Days 5 h 55 m 39 sec
Reputation Power: 316
would be better if you created one table more, which will contain the choosed products:

shopping_basket
basketid (PK)
custid

shopping_basket_products
basketid (FK)
prodid (FK)
Quantity

and then have product 1 and 3 at one row each.
Comments on this post
r937 agrees: yes!! do not use the dreaded, evil, comma-delimited list of values in one column

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesDatabase Management > Insert a multiple selection into a table


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