disecting individual data from a group

rick roberts

Registered User.
Local time
Today, 18:54
Joined
Jan 22, 2003
Messages
160
my database contains a series of pictures and a record of who is in the picture. in group pics people are named together in one box eg. Tom Dave Jane. i want to be able to choose a name from a combo box and show all pics that contain a certain person however to d othis i would have to disect the multiple names somehow and list them individually. can anyone think of a way of doing this without having to seperate each name into individual boxes. i realise i havent explained my problem too well
 
Well, much depends on how you have your data organized but if you are searching on a field that contains text strings (names), and you are choosing the name in a combo on a form (and which stores the text name not a numeric identifier for the person), you might use a criteria of

Like "*" & Forms!FormNameHERE!ComboNameHere & "*"


This should select all records in that field that contains the text string selected in the combo.

Now, here's the bit where I point out that you really should NOT be storing multiple pieces of information in one 'box'. What you should have is a separate but linked table that links the pictureID to each person in the table (one record or row per person per picture). I strongly suggest you larn about table normalization or you'll face much more difficult situations in the future.
 
i have used excactly the same criteria that you mention and it works fine -- for the first event of that name -- but in the combo box the name comes up many times if it is the first of a group - 'bob jane dave' and 'bob sally' for instance --thats what im trying to get rid of - ive also realised that if a name is never the first of a group then they wont show at all
could you explain a little more about creating the seperate table
 
but in the combo box the name comes up many times if it is the first of a group - 'bob jane dave' and 'bob sally' for instance

A combo box can only store ONE value. I assumed that you were using individual names in the combo itself while the field you were searching containing the multiple names.


could you explain a little more about creating the seperate table

Ok, your table structure should probably look something like this:

tPicture
PictureID (auto,pk)
PictureLocation(text)
PictureDate (date/time)

tPerson
PersonID (auto,pk)
PersonFirstName
PersonLastName

tPicturePeople
PicturePeopleID (auto, pk)
PictureID (long)
PersonID (long)

In this situation, tPicturePeople is a junction table that links a person, or many persons, to each picture. And likewise, it functions to link a picture, or many pictures, with one person.

Note that if two people are in pictureID '5' there are two records in the junction table: one for each person.

However, each person has their information stored separately in the tPerson table only once. Likewise, information about each picture is stored only once.

Also, notice how all the information is stored separately: first names go into one field, last names in another....you could also put a field for middle names or suffixes etc too. There's no cramming of several pieces of information into one 'box'. The reason for this is that it's extremely easy to combine data from various fields into one whenever you want, but it's very difficult, sometimes impossible, to split data that has been mashed together inappropriately like in your example: especially if no standard convention was used when mashing things together in the first place.

Essentially, you need to re-organise your data. Read up on table normalization to get a better understanding of how you should structure databases. Also, read up on how to use forms/subforms for data entry to populate the tables easily. You may also want to investigate using the notinlist event of combo boxes to add new people to the tPerson table.
 
im grateful for your very informative and well structured reply your answers have been clear and precise and i think i know where to go from here
thanks again
 

Users who are viewing this thread

Back
Top Bottom