473,385 Members | 1,856 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,385 software developers and data experts.

Delete row from a list box

489 256MB
I'm probably going about this the wrong way so any suggestions are appreciated.
I have a club data base with members I want to associate family members to a member. I created a associates table with the members club number, the associates club number, and the associates Name. I've created a combo box on the main members form where the user can select the associate and add it to the associates table, also on the main members form I have a list box where the associate members show up. This works fine, what I need to do is be able to double click on one of the associates and be able to go to that persons record or remove that associate from the list box. Because the associates member number is the second column in the Associates table and there can be multiple associates for any given member how do I find the correct associate to look up or remove.

I hope this is clear what I'm looking to do. If not let me know and I'll try again.
Jul 11 '12 #1
4 2312
zmbd
5,501 Expert Mod 4TB
What is the primary key in the table? This is what you'll need to be able to remove the record.
-z
Jul 11 '12 #2
CD Tom
489 256MB
The primary key in the associates table is the main members clubmembernbr the associates number is the second in the table. There really isn't a primary key because there can be more than one associate assigned to the main club member. Is there a way to tell when you select a item from a list box what record we are pointing to? If I knew that then I could get the associates clubmembernbr and us it to either look up the record or delete it.
I hope this is a little clearer.
Jul 11 '12 #3
zmbd
5,501 Expert Mod 4TB
One more question:

In one case you talk about a cmbobox where in the [associateclubnumber] is entered.
Then you have a list box with the [membersclubnumber]. Later in the post you talk about removing the [associateclubnumber] from the list box... do you mean the combobox? We also need to have an idea as to the data source for the combobox and listbox.

To handle finding the record you're interested in:

Without a primary-key , either as a single field within the table or as a composite key, you cannot ensure that you have a unique record.

So let's look at how we can determine how to locate your record.

For the sake of my sanity lets try something
Expand|Select|Wrap|Line Numbers
  1. [membersclubnumber] = 100 (for member 1)
  2. [membersclubnumber] = 200 (for member 2)
  3. [associateclubnumber] = 911 and [associatename] = john
  4. [associateclubnumber] = 912 and [associatename] = jane
  5. [associateclubnumber] = 921 and [associatename] = rob
  6. [associateclubnumber] = 922 and [associatename] = reba
Case 1 - this is what I expect your table to look like:
Expand|Select|Wrap|Line Numbers
  1. [membersclubnumber][associateclubnumber][associatename]
  2. [100][911][john]
  3. [100][912][jane]
  4. [200][921][rob]
  5. [200][922][reba]
Case 2 - however, without some logic to prevent duplications then you could get
Expand|Select|Wrap|Line Numbers
  1. [membersclubnumber][associateclubnumber][associatename]
  2. [100][911][john]
  3. [100][912][jane]
  4. [200][921][rob]
  5. [200][922][reba]
  6. [100][912][jane]
  7. [200][921][rob]
  8. [100][912][jane]
  9. [200][921][rob]
  10. [200][922][reba]
This is a mess. In order to prevent this, and even though I dislike them, I would use a composite primary-key against [membersclubnumber] and [associateclubnumber] this ensures that case 2 cannot happen. (if you use an autonumber field etc... you still risk case 2 without any logic to prevent it from happening) The only advantage to using the composite key is that it doesn't require any VBA/Macro code to prevent duplicate records... it does however, make the VBA code and SQL more difficult so I often add an indexed autonumber field to such tables... easy enough to find the record, pull the field's value... not really the best practice; however, a compromise I make for my sanity.

Now you only need to create a query that finds the record based on [membersclubnumber] and [associateclubnumber]. From there, there are several methods to edit the record (directly from the detail section of a form for one)... as for deleting the record, there's the delete query.

-z
Jul 11 '12 #4
CD Tom
489 256MB
After going over your comments I realize that the associates table is designed wrong. By making the Assoc mbr number the primary key everything works. There can only be one Associate member assigned to an individual member. By changing this everything works great. Thanks for your comments they helped.
Jul 11 '12 #5

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

Similar topics

5
by: flupke | last post by:
Hi, i'm having trouble with deleting elements from a list in a for loop ============== test program ============== el = print "**** Start ****" print "List = %s " % el index = 0 for line...
7
by: Nemo | last post by:
Hello Folks, I need to manipulate a list of char strings as follows, but when I want to delete the pointer created with new at the end, delete operator crashes, any idea? char* list;...
13
by: Nemo | last post by:
Hello Folks, I need to manipulate a list of char strings as follows, but when I want to delete the pointer created with new at the end, delete operator crashes, any idea? char* list;...
7
by: python | last post by:
after del list , when I use it again, prompt 'not defined'.how could i delete its element,but not itself? except list.remove(val) ,are there other ways to delete list 's elements? and , I...
4
by: bitshadow | last post by:
I've been working on a link list implementation and I'm driving myself crazy trying to understand something. assuming i have a list and i have the following quasi pseudocode: add(list *head):...
6
by: valerij | last post by:
Please help. I have been on this problem for a week now. I am using Windows 98SE, Microsoft Visual C++ 6.0 The following program only works when the function is not called, BUT the function does...
7
by: xianwei | last post by:
Guys: The problem come from a book Data structures and Algorithm Analysis in C First, some code in list.h struct Node; typedef struct Node Node; typedef struct Node *PtrNode;...
0
by: shapper | last post by:
Hello, I have a Generic.List(Of String) with 100 elements. I want to sort it and delete the last 40 elements. Can this be done without a loop? And if not, can I convert it to an array and do...
1
Jezternz
by: Jezternz | last post by:
Scriptaculous needs an official forum but does not have one so I am asking here :). note you will need to be familiar with scriptaculous to help me here. Basicly I have a script that has a...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

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.