Page 1 of 2 12 LastLast
Results 1 to 15 of 23
  1. #1
    gaker10 is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jun 2014
    Posts
    262

    The infamous Append Query with a multi-value field

    I've seen posts about this in several places. Most of them don't have solutions. The ones that do, I have tried and still cannot get it to work.

    I had the same problem as described in this post, and I tried the proposed solution: https://www.accessforums.net/queries...lds-43565.html

    And now I get this error: "An INSERT INTO query that contains a multivalued field cannot contain another field."

    My SQL code:

    Code:
    INSERT INTO DRAWINGS ( Drawing, [Primary], AlternateA, AlternateB, CageCodeA.[Value], CageCodeB.[Value], CageCodeC.[Value], Revision )
    SELECT [Drawings Not in DRAWINGS].[Drawing#], [Drawings Not in DRAWINGS].[PrimaryP/N], [Drawings Not in DRAWINGS].[AlternateAP/N], [Drawings Not in DRAWINGS].[AlternateBP/N], [Drawings Not in DRAWINGS].CageCodeA, [Drawings Not in DRAWINGS].CageCodeB, [Drawings Not in DRAWINGS].CageCodeC, [Drawings Not in DRAWINGS].Revision
    FROM [Drawings Not in DRAWINGS];
    The multi value field is the three CageCodes (A, B, and C). This append is running based off a linked Excel that is set up identically to my table.

    How do I get this to work?

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    I don't think you can add data to the non-MV and MV fields in the same INSERT action. As the article states: "... you cannot use an append query that references a table that contains a multivalued field. For example, the following query is not valid:..."

    This will probably require two INSERT actions.

    Why are those 3 field MV types if you are only entering one value into each?
    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.

  3. #3
    gaker10 is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jun 2014
    Posts
    262
    Each MV field can have any number of values, including none.

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    Okay - is the issue resolved by the suggestion?
    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.

  5. #5
    gaker10 is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jun 2014
    Posts
    262
    Would the SQL code look similar to my usual INSERT INTO? With the .Value operator on my MV fields?

  6. #6
    gaker10 is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jun 2014
    Posts
    262
    Also, would I have to do this as a separate query?

  7. #7
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    As I said, probably two queries. Review https://support.office.com/en-us/art...n-US&ad=US#bm7
    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.

  8. #8
    gaker10 is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jun 2014
    Posts
    262
    I get the same error as in post #1. My code:

    Code:
    INSERT INTO DRAWINGS ( CageCodeA.Value, CageCodeB.Value, CageCodeC.Value )
    SELECT [DrawingsImport].[CageCodeA], [DrawingsImport].[CageCodeB], [DrawingsImport].[CageCodeC]
    FROM DrawingsImport
    WHERE [DrawingsImport].[Drawing#] = [DRAWINGS].[Drawing];
    DrawingsImport is the linked Excel.

  9. #9
    gaker10 is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jun 2014
    Posts
    262
    Maybe it should be an update query?

  10. #10
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    Did you review the link? The last 3 items are relevant to your situation.

    You are trying to add MV data to multiple parent records. I don't know if this is possible.

    I don't use MV fields.
    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.

  11. #11
    gaker10 is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jun 2014
    Posts
    262
    Yes. The examples in the link are too specific. I can't name a specific value or ID (of which does not exist). It's however many records are in my linked Excel.

  12. #12
    gaker10 is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jun 2014
    Posts
    262
    Not to mention I need to update three MV fields, whereas the examples specify one, unless I need three queries for each MV field.

  13. #13
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    Isn't Drawing the ID field?

    I don't know if more than MV field can be in the same action, you will have to experiment, which is exactly what I would have to do.
    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.

  14. #14
    gaker10 is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jun 2014
    Posts
    262
    Technically, yes. But when I treat it as one in my code, it doesn't work. The following yields no results. The drawing number was entered just fine. DrawingImport Query is just a query version of my linked Excel.

    So I tried a query with just CageCodeA:

    Code:
    UPDATE [DrawingsImport Query] INNER JOIN DRAWINGS ON [DrawingsImport Query].[Drawing#] = DRAWINGS.Drawing SET DRAWINGS.CageCodeA.[Value] = [DrawingsImport Query].[CageCodeA]
    WHERE (((DRAWINGS.Drawing)=[DrawingsImport Query].[Drawing#]));
    Design:
    Click image for larger version. 

Name:	mvquery1.png 
Views:	23 
Size:	126.9 KB 
ID:	19064

  15. #15
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    Unless there is some compelling reason to use MV field (I think they are needed for web database through SharePoint), I recommend you abandon them in favor of a normal related table. I know the MV field uses a hidden related table but much easier to deal with a native table.

    Also, multiple similar name fields with same type data is not a truly normalized structure.
    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.

Page 1 of 2 12 LastLast
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Append Query - Multi-Valued Fields
    By lynthel in forum Queries
    Replies: 8
    Last Post: 08-03-2017, 11:46 AM
  2. Multi Field Query
    By dsthome in forum Queries
    Replies: 10
    Last Post: 03-21-2013, 09:21 PM
  3. Replies: 5
    Last Post: 08-23-2012, 09:33 AM
  4. Replies: 6
    Last Post: 05-10-2012, 10:57 AM
  5. Append Query - Multi-Valued Field
    By catat in forum Queries
    Replies: 0
    Last Post: 05-11-2010, 01:52 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