- Local time
- Today, 15:18
- Joined
- Feb 19, 2002
- Messages
- 46,962
Only the subform method will allow you to add or delete artists. So, if this is an update form, you probably want to go with the subform.
Thanks @bastanuIf you don't want to use a subform as Pat suggested (probably the best approach) you can use the "concatenate" function to put togheter all the names in one record, you should do it in the form in an unbound control if the record source returns more than one (current) record.
Microsoft Access tips: Concatenate values from related records
Return a string containing the values of related records.allenbrowne.com
http://forestbyte.com/vba-code-samples/ (JoinFromArray).
Cheers,
Vlad
Hi @Pat HartmanWhy do you not want to use a subform? No code is required when you take advantage of Access![]()
SELECT tblArtistsAndRecords.RecordID, tblArtistsAndRecords.ArtistID, tblRecords.Title, tblRecords.FormatID, tblRecords.Released, tblArtistsAndRecords.Main
FROM tblRecords INNER JOIN tblArtistsAndRecords ON tblRecords.RecordID = tblArtistsAndRecords.RecordID
ORDER BY tblRecords.Released;
Thank's @MickJavWhat you need for your tracks subform is whats called (I think I read that somewhere lol) is an auto lookup Query Like below
Which is what I use for my artists and recordings to show all recordings for the selected Artist
SQL:SELECT tblArtistsAndRecords.RecordID, tblArtistsAndRecords.ArtistID, tblRecords.Title, tblRecords.FormatID, tblRecords.Released, tblArtistsAndRecords.Main FROM tblRecords INNER JOIN tblArtistsAndRecords ON tblRecords.RecordID = tblArtistsAndRecords.RecordID ORDER BY tblRecords.Released;
1. You never corrected anyone who was suggesting other methods.I do not know what gave you the impression that I do not want to use subforms.
Thanks for your input @Pat Hartman1. You never corrected anyone who was suggesting other methods.
2. Your original db did not use a subform for artist because your relationship was 1-m rather than m-m.
Here is a sample that shows how a m-m relationship works from both sides.
Hi @Pat HartmanAs recently as #30 (and I don't see anything newer), your relationship was still 1-m.
I'll go away now since you don't need my help.
Happy New Year.
And several of us have told you this is wrong. It will NOT do what you want to do. We do understand your requirements.Below you see a picture of the db that I am trying to work with today (it is also in my first post in this thread).
Hi @Pat Hartman I added the Shows as in a earlier topic posted on the same topic as this one he had commented how he wanted to Create Playlists for his shows.Mic is tracking shows. You won't. If you were, you would also need a Show table.
Thanks @MickJavI have a feeling you are seeing compilations that somebody with a lot more experience wont see.
I did post a ERD which would do 90% of what you want.
Before I started work on my DJ 2020 I asked for advice on the table structure which helped me stucture my system.
I do think you are stuggling with something that will never do what you want looking at it I can't make it work
I think your maybe trying to jump before you can walk what You want is a very complex beast that you will need to understand relationships far better than you do, asking for people to help do it for you will not help when you start coding the forms as you need a picture of how it all fit together.
I've edited my last ERD To include what you need to to with the tracks but even that is not complete.
hope it helps mick
View attachment 87903
Thanks @Pat HartmanAnd several of us have told you this is wrong. It will NOT do what you want to do. We do understand your requirements.
When you put the artist ID on the record table, you are restricting the record to a SINGLE artist. That is the problem. There is a m-m relationship between artist and record. An artist can perform on many records and a record may have many performers. Therefore, you MUST have an intermediate table which is commonly called a junction table. This table is used to implement the TWO simultaneous 1-m relationships. It looks like tbl_artist_music is the junction table so you can connect multiple artists to each song.
You MUST remove Artist Id from the record table and you MUST remove both instances of artist id from the music table. You should also add a type CD to artist so you can distinguish musicians from singers if you want to. You can also add a roleCD to the tbl_artist_music if you want to know what each artist did on each song. You have other places where you have pathological relationships. In a 1-m relationship, the FK goes in the "many" table. Think of parents and children. parents can have many children but a child can have only one set of biological parents. That means that the ParentID goes into the child table. If you want to find the children of a parent, you join the parent table to the child table. If you try to put the ChildID on the parent table, how many slots are you going to have to provide? That's what you did in the music table. You added two instances of artist. Well, that might take care of a duet but it doesn't handle a trio or a quartet.
The sample I loaded shows how to use the junction table, tbl_artist_music from each direction. You will want to view the artists for a song and you will also want to view the songs performed by an artist. There is a summary in your case because you might want a list of artists for a record. That is a summary and you do that with a totals query which will return one row for each artist no matter how many songs he performed on the record. If he did them all, you'll get one row. If there were 12 songs done by 4 performers, you'll get 4 rows. If you ever find yourself adding columns to a table and prefixing (or suffixing) them, think again. this is almost always a repeating group and a repeating group is indicative of a 1-m relationship and the "group" needs to be rows in a new table rather than columns in this table. That allows you to have an infinite number of instances. Do NOT talk yourself into storing item1 and item2 because there's ONLY two of them. Do it right the first time. You are seeing this with the duet issue because there are not just duets as we all know.
Try to understand the model that Mic posted and do some reading on normalization. Your schema is incorrect and it is getting in your way. Just FYI, there are very few instances where relational models developed independently by different experts will differ in anything but minor details. Mic is tracking shows. You won't. If you were, you would also need a Show table.
Opinion: using long prefixes as you are is not productive in this environment where we have intellisense. When I was writing COBOL 50 years ago, I used prefixes but not today since the object itself provides the context. When you open your tables in DS view, it must be really annoying to never be able to see an actual column name. All you ever see are prefixes unless you make the columns extra wide.
Advice: the sooner you fix a problem (like removing the prefixes and fixing the schema), the less they will impede your development. Don't just throw up your hands because you think you are too far in to fix some things. It is really important to get your schema straight before you spend a lot of time developing form/queries/reports. Every object you make that uses a bad schema design will ultimately have to be changed. Get your foundation fixed so you can move on. Access has tools that will help you with column name changes. They are extremely dangerous so I always turn them off by default (Name AutoCorrect or AutoCorrupt as we call it) should ALWAYS be off UNLESS you actually want it to do something for you. What gets people in trouble is that they do not understand how/when the changes get propagated and so you can end up with quite a muddle if you are not careful. You have to change the names in an orderly way. Start with a backup and make several throughout the process. Change the column names in all the tables. Then open each object in the database to propagate the change. The final step is to compile and fix the compile errors caused by the name changes.
Thanks @The_Doc_Mantbl_music still contains a normalization violation in that it has data for Artist1 and Artist2. If those fields are still active in your design, that is an error because surely if you have two artists, you could have three artists.