Results 1 to 3 of 3
  1. #1
    pdxrichard is offline Novice
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    5

    How to write to a dao.reocrdset2 multi-select/ list field

    I see examples of how to read a list field but no example of how to write to one. I am taking an excel spreadsheet and importing it with code but one of my table fields is a list select field and the online example only shows how to read a field but not write to it. Can anyone give me an example of how to write to such a field? This is the link I am referencing: https://docs.microsoft.com/en-us/off...XAJwpzC2nK_7ek



    In my code I thought I could simply look up the matching option from the option table and then record the value to the list field called "StyleOpt". But of course this doesn't work.


    '//Lookup styles first in the style table and then save the ID to the table
    'Dim rsSTY As DAO.Recordset2
    'Dim fldSTY As DAO.Field2
    '
    'Set fldSTY = rsWIP("Style") <--- this is the list field
    '
    ' Set rsSTY = modDB.DBWOP.OpenRecordset("SELECT * FROM tblWIPStyleOpt WHERE (([StyleOpt] = """ & xlSheet.Cells(i, 6).Value & """))", dbOpenDynaset)
    '
    ' Select Case (rsSTY.EOF)
    ' Case False: rsWIP![Style] = rsSTY![StyleOpt]
    ' Case Else: rsWIP![Style] = Null
    ' End Select
    '
    ' rsSTY.Close
    ' Set rsSTY = Nothing

  2. #2
    orange's Avatar
    orange is offline Moderator
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,722
    Most readers with Access experience would advise you to avoid multi-valued fields.
    I suggest you describe to us in 3-4 lines of simple English what you are trying to accomplish.
    Once readers understand What, you will get more focused advice on How to do it with Access.

    As for multiselect listbox, you may get some insight from this link.
    Good luck with your project.

  3. #3
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,898
    See if this helps https://support.office.com/en-us/art...624e1e323a#bm7

    I agree, multi-value fields are an aggravation, I never use.
    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: 1
    Last Post: 02-15-2016, 04:48 PM
  2. Replies: 15
    Last Post: 11-20-2013, 04:30 PM
  3. Replies: 6
    Last Post: 08-15-2012, 04:05 PM
  4. Replies: 5
    Last Post: 07-26-2012, 12:59 PM
  5. Replies: 1
    Last Post: 10-22-2010, 10:11 AM

Tags for this Thread

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