Results 1 to 5 of 5
  1. #1
    Adam9595 is offline Novice
    Windows 11 Office 365
    Join Date
    Dec 2024
    Posts
    2

    Question Transfer Content from table into another table with attachment

    Hi everyone!



    i want to transfer my table "db_SelectUploadFiles" (Source) into a new SharePoint-table "db_Belegverzeichnis" (Target). The columns are as follows:

    Source.Belegnummer = Target.Beleg
    Source.Buchungsdatum = Target.Buchungsdatum
    Source.Feld1 = Target.Anlage

    "Feld1" and "Anlage" are attachment fields where files can be attached. Unfortunately, I cannot copy the tables using the INSERT INTO syntax because Access gives me an error stating that an INSERT INTO query cannot contain a multivalue field.


    My code:

    ******
    Private Sub cmd_02_01_01_Save_IstKosten_Click()
    Dim db As DAO.Database
    Dim AddFileSQL As String

    Set db = CurrentDB

    AddFileSQL = "INSERT INTO db_Belegverzeichnis (Beleg, Buchungsdatum, Anlage) SELECT Belegnummer, Buchungsdatum, Feld1 FROM db_SelectUploadFiles;"
    db.Execute AddFileSQL, dbFailOnError
    *****


    How can I solve this problem?

    Thank you!
    Adam

  2. #2
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    6,556
    Copy the table and delete the relevant fields you do not want from the new table..
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  3. #3
    Adam9595 is offline Novice
    Windows 11 Office 365
    Join Date
    Dec 2024
    Posts
    2
    Hello Welshgasman,
    A simple copy of the table is not sufficient for me, as the Source table is dynamic and can change regularly whenever the user adds a different attachment via the form or changes the "Belegnummer" or "Buchungsdatum."
    There is also a button in the form that writes the record from the Source table into the Target table as well.

  4. #4
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    6,556
    I have never used sharepoint, but can that link to a query?, then use a query from your table.
    You're initial logic would not work if that table is so dynamic, it would soon be out of date.
    Trying to keep two tables in sync is very difficult. Better to have one and get another view of the data?
    Why the need to reduce the data, just grab what you need with a query.
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  5. #5
    June7's Avatar
    June7 is offline VIP
    Windows 11 Access 2021
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,771
    By "SharePoint table", do you man a SharePoint list?

    Never used SharePoint either. From what I've read, a list can support one Attachment field. But this appears to use an Export operation, not an SQL INSERT.

    Copying records that have multi-value fields (Attachment is a type of multi-value) gets complicated. Because copying multi-value field to another table actually involves a separate INSERT action for new records. Multi-value fields really just hold "pointers" (or links) to a hidden dependent table where each value is a record.

    This is one user's solution: "I have found that I can still run the Append query if I do not use the "*" function but list all fields except the attachment. I can then manually copy the attachment column (CTRL C) and paste it (CTRL V) into the updated table."

    Fairly common topic. Here is one discussion https://www.access-programmers.co.uk...nother.246743/
    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.

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

Similar Threads

  1. Replies: 17
    Last Post: 09-27-2019, 03:33 AM
  2. Replies: 3
    Last Post: 12-23-2018, 04:22 PM
  3. Vba code to transfer attachment to a table
    By ludovic_44 in forum Access
    Replies: 1
    Last Post: 01-10-2015, 02:01 PM
  4. Replies: 2
    Last Post: 01-03-2015, 07:18 PM
  5. How do you file save an 'Attachment' content through code?
    By morespamforya in forum Programming
    Replies: 3
    Last Post: 08-06-2010, 08:58 AM

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