Results 1 to 2 of 2
  1. #1
    dccjr's Avatar
    dccjr is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    Nov 2012
    Location
    Colorado Springs, CO
    Posts
    138

    Saving List box values to a table

    I am trying to save each list box value (they are paths for attachments) to a table. I would also like to incorporate the code to copy these files to a new location. I have gotten this far, but am not sure how how to copy the files to a new location. The files are loaded to the list box via a file dialog box.



    Code:
    Dim i As Integer
            For i = 0 To Me.ListBoxName.ListCount - 1
               Me.lstAttach.List (i)
               iAttachSQL = "INSERT INTO AttachmentFiles (File" & intAttachNo & ")" _
               & "VALUES ('" & Me.lstAttch.List(i) & endSQL
               CurrentDb.Execute iAttachSQL
            Next i
    My table has about 10 fields (File1, File2, etc). As it cycles through the items in the list box, I want to save them to each field, chaging the the field name (File?) incrementally. Pointers or ideas? I have never tried to use a field name containing a variable.

    When I save the file to the new loaction, I would like to rename it to using a value from a textbox plus an incremental number. Am I trying to do too much? Help.

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    Use the i variable in the concatenation.

    "INSERT INTO AttachmentFiles (File" & i + 1 & ")"


    Try FileCopy function:

    FileCopy(SourceFile, DestinationFile)
    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: 21
    Last Post: 10-05-2012, 11:36 AM
  2. Table with list of values - primary key filed
    By snoopy2003 in forum Database Design
    Replies: 1
    Last Post: 02-23-2011, 09:29 PM
  3. Master list table with changing values.
    By evander in forum Database Design
    Replies: 11
    Last Post: 06-24-2010, 07:40 AM
  4. Replies: 1
    Last Post: 11-11-2006, 08:23 PM
  5. saving a list box to access table
    By newguy357 in forum Forms
    Replies: 0
    Last Post: 05-05-2006, 12:22 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