Results 1 to 9 of 9
  1. #1
    cherold is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Dec 2014
    Posts
    82

    more complicated structured wrecks ability to edit rows; any way around that?

    I'm trying to split one table into two, but I find that while my old query involving that table joined with a reference table allows me to edit and add records, a query joining the two new tables with the reference table does not allow this. I'm wondering if this is just too complex to still allow edits or if a better query would give me back that functionality.



    DETAILS:

    Originally I had a table called [Songs] and a reference table called [LPContents] that told me what albums each song in the table was on. I created a query called [Song query]
    Code:
    SELECT *
    FROM LPContents INNER JOIN Songs ON LPContents.song_id = Songs.SongID;
    If I run this query I am able to edit the rows or add a new row.


    Then I split [Songs] into two tables, [Songs (Compositions)] and [Recordings] and created this query, called [Song Query (New)]:
    Code:
    SELECT *
    FROM Recordings INNER JOIN ([Songs (Compositions)] INNER JOIN LPContents ON [Songs (Compositions)].SongID = LPContents.song_id) ON Recordings.song_id = [Songs (Compositions)].SongID;
    In this latter case, I cannot edit or add rows. Is there any way to write this query so I'm able to add/edit?

    (I should probably explain that the Join on [LPContents] is needed for when I query [Song query]/[Song query (New)] from a Subform that has access to an LPID variable. Like this:
    Code:
    SELECT *
    FROM [Songs query (New)]
    WHERE ((([Songs query (New)].[LP_id])=[LPID]))
    ORDER BY [Songs query (New)].Side, [Songs query (New)].Track;
    )





    Here are abbreviated versions of the tables themselves, in case they're needed for clarity:

    LPContents
    Code:
    SongKeyID
    song_id
    LP_id
    Songs:
    Code:
    SongID
    Title
    ArtistID
    Rating
    Songs (Compositions)
    Code:
    SongID
    Title
    Recordings:
    Code:
    RecordingID
    song_id
    ArtistID
    Rating

  2. #2
    davegri's Avatar
    davegri is online now Excess Access
    Windows 10 Access 2016
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,402
    I wouldn't divide the table into two tables. Just put a flag in the original file to indicate the type of each record.

  3. #3
    cherold is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Dec 2014
    Posts
    82
    Not sure what you're suggesting so let me explain what I'm trying to get to. The goal is to have a table of songs and one of song recordings. So Songs contains In My Life. Recordings has records for the song as recorded by the Beatles and another entry for the song as recorded by Judy Collins. In the old, working version, these two songs are unrelated.

    The information you want for a written song (title, composer, lyrics) is substantially different from that you need for a recording (album, track #) which is why I divided them up.

  4. #4
    CJ_London is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,409
    I'm with davegri on keeping one table. But to answer your question - depends in what fields you want to be able add/edit but try using SELECT DISTINCTROW (the unique Records option in the query properties) - that may work, you may also need to change your joins to left joins as well. Basing forms on multi table queries is not recommended, generally speaking the rule should be one form one table which is accomplished using a main form with subforms.

  5. #5
    Micron is online now Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,776
    Basing forms on multi table queries is not recommended, generally speaking the rule should be one form one table which is accomplished using a main form with subforms.
    On that we do not agree.
    If the idea is to normalize everything and we end up with multiple tables, what if my form needs fields from 5 tables? One main form and 4 subforms? Not me.

    IIRC, any DISTINCT predicate will make a query read only. For a list of possible reasons, see
    http://allenbrowne.com/ser-61.html

    EDIT - To be clear, I'm not referring to a situation like ORDERS and order line items, which is where your statement would be most applicable. I'm referring to where you have many related tables that may or may not be involved in a 1 to many relationship like orders. I've seen that comment many times and to me, the interpretation is more all encompassing. Perhaps I read too much in to the intent, but I'm trying to guess how a novice would likely interpret that.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  6. #6
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,892
    Songs/Recordings relationship seems reasonable to me.

    tblSongs
    SongID
    SongTitle
    Composer (though this gets complicated when there are multiple composers given credit, and then the lyricist can be different from the music composer)
    Lyrics

    tblRecordings
    RecordingID
    fkSongID
    fkArtistID
    Rating

    And more complication to associate albums with recordings.

    tblAlbums
    AlbumID
    AlbumTitle
    Studio

    tblAlbumsRecordings
    fkAlbumID
    fkRecordingID

    I have to agree that, in general, 1 form should edit 1 table. That form RecordSource can include lookup tables so related info can be displayed but fields from lookup tables should not be edited through that form.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  7. #7
    CJ_London is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,409
    On that we do not agree.
    If the idea is to normalize everything and we end up with multiple tables, what if my form needs fields from 5 tables? One main form and 4 subforms? Not me.
    I was referring to forms where there is a requirement to add/edit/delete

    IIRC, any DISTINCT predicate will make a query read only
    agree about DISTINCT, to be clear I was suggesting DISTINCTROW

  8. #8
    Micron is online now Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,776
    Quote Originally Posted by Ajax View Post
    agree about DISTINCT, to be clear I was suggesting DISTINCTROW
    I saw that. To me, either would be a DISTINCT predicate so I take it that Allen's comment applies to both.

  9. #9
    cherold is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Dec 2014
    Posts
    82
    Just a quick note to say I figured this out. It was actually a stupid error because I was repurposing one table and, because of my dividing my other table into separate tables the repurposed table had fieldnames that didn't correlate with my new tables. So I wound up with two tables each joined through the same field in the third table.

    So it was just pure sloppiness. Sorry to bother y'all with something so dumb!

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 4
    Last Post: 12-07-2017, 08:31 AM
  2. Replies: 2
    Last Post: 09-17-2014, 09:35 AM
  3. Complicated Query (Interleave rows?)
    By crozfader in forum Queries
    Replies: 8
    Last Post: 09-19-2011, 12:15 PM
  4. Structured Activity
    By Logix in forum Queries
    Replies: 2
    Last Post: 06-10-2010, 06:05 AM
  5. Replies: 1
    Last Post: 06-01-2009, 01:09 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums