Results 1 to 6 of 6
  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 Items from a List Box to seperate fields in a table

    First, thanks to all of you guys and gals who give your time to provide assitance and solutions to us newbies. It is really appreciated.



    I have a listbox that contains one or more file paths. I would like to save each of these paths to a field in a table record. I am also copying the file itself to a central location. I have gotten this far, but am having syntax probelms.

    Code:
    For i = 0 To Me.lstAttach.ListCount - 1
               iAttachSQL = "INSERT INTO AttachmentFiles (File" & i & ")" _
               & "VALUES ('" & Me.lstAttach(i) & endSQL
               CurrentDb.Execute iAttachSQL
              FileCopy(Me.lstAttach(i), "X:\Operations\Manufacturing\Root Cause Analysis\RCADatabase\" & Me.tbxPartNo.Value & "-" & (i))        Next i
    It is throwing a sytax error on my FileCopy line. I am guessing that it has to do with the (i) variable, but not sure how to correct it. Any ideas?
    Last edited by dccjr; 04-26-2013 at 03:57 PM. Reason: Update line

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,632
    Don't enclose the variable i within ().
    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
    dccjr's Avatar
    dccjr is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    Nov 2012
    Location
    Colorado Springs, CO
    Posts
    138
    Ok, The line is

    Code:
    FileCopy(Me.lstAttach  i  ,"X:\Operations\Manufacturing\Root Cause Analysis\RCADatabase\" & Me.tbxPartNo.Value & "-" & i)
    It now throws a compile error "Expected list seperator or )"

  4. #4
    dccjr's Avatar
    dccjr is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    Nov 2012
    Location
    Colorado Springs, CO
    Posts
    138
    OK, so I have decided to concatenate these before the FileCopy command, as such:

    Code:
    strFileName = "X:\Operations\Manufacturing\Root Cause Analysis\RCADatabase\" & Me.tbxPartNo.Value & "-" &  (i)
    strListSource Me.lstAttach & (i)
    FileCopy(strListSource, strFileName)
    Both with and without the () around i, I am getting "Expected: ="
    I must admit this way is cleaner, but still no better off.

  5. #5
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,632
    Sorry, I meant just the (i) at the end, not the first one, didn't even see it.

    FileCopy(Me.lstAttach(i), "X:\Operations\Manufacturing\Root Cause Analysis\RCADatabase\" & Me.tbxPartNo.Value & "-" & i)
    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.

  6. #6
    dccjr's Avatar
    dccjr is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    Nov 2012
    Location
    Colorado Springs, CO
    Posts
    138
    Thanks. It works great now.

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

Similar Threads

  1. Saving List box values to a table
    By dccjr in forum Programming
    Replies: 1
    Last Post: 04-16-2013, 05:29 PM
  2. List in Report Shows All Items in Table, But I Only Want...
    By italianfinancier in forum Programming
    Replies: 1
    Last Post: 05-28-2011, 02:42 AM
  3. Highlighting Items in List Box from Table Data
    By swalsh84 in forum Programming
    Replies: 2
    Last Post: 01-25-2010, 08:55 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