Results 1 to 4 of 4
  1. #1
    illicited is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Mar 2013
    Posts
    28

    Newb VBA coding help cmd button that copies records

    OK I'm new to VBA so I need some guidance on how to code this.

    What I got is a continuous subform with a query as its source with about 4 or 5 fields and usually about 6 or so records. I need a command button that reads in the values of a multiselect box that represents one of those fields (extended so multiple values can be selected) as variant or whatever and for each value of the multiselect box copy all the data in the subforms recordset (4 to 5 fields and 6 or so records) into the same table the query is pulling from under each new multiselect value. Basically I have records that I need to copy into the same table but one field needs to change representing a new location for all these items.



    Sorry if the description of the problem is bad, I can provide screens or the db if necessary.

    Thanks,

  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,929
    Multi-select box means a multi-value field. Makes it really, really hard to accomplish what you want. Review http://msdn.microsoft.com/en-us/library/bb258183.aspx

    I NEVER use multi-value 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.

  3. #3
    illicited is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Mar 2013
    Posts
    28
    I didn't intend on using a multi-value field, but maybe there is a different way to do this. All fields contain one value, I need to copy all of the fields other than plant and change plant to 2, then to 3, then to 4, etc based on all the values selected from the multiselect textbox. See picture of the query.
    Click image for larger version. 

Name:	querypic.png 
Views:	11 
Size:	16.3 KB 
ID:	12192

  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,929
    So users could select plants 2, 5, 7, etc and you want a set of records for each. I would use unbound multi-select listbox in header section of a Continuous form, code would loop through the listbox and if row selected, run an INSERT SELECT sql action.
    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. Coding an "update" button
    By Nick F in forum Programming
    Replies: 6
    Last Post: 11-16-2012, 09:38 AM
  2. Query to concatenate records - newb
    By bentod in forum Queries
    Replies: 7
    Last Post: 10-08-2012, 12:06 PM
  3. Button Coding
    By yamie in forum Programming
    Replies: 3
    Last Post: 02-22-2010, 10:45 AM
  4. Adding VB code on a embedded coding for a button
    By cwwaicw311 in forum Programming
    Replies: 1
    Last Post: 02-20-2010, 12:25 PM
  5. VB coding for saving when click on save button in form
    By cwwaicw311 in forum Programming
    Replies: 1
    Last Post: 02-04-2010, 11:11 PM

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