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

    Sometimes repeating data sometimes not - How to handle data entry of this?

    I have posted a screen of the form I'm working on and its underlying relationship. The form is made up of a main form and a subform, the main form contains general non-changing information about a product and the subform contains data specific to each different plant. This data in the subform has the potential to repeat from plant to plant, but it also can change from plant to plant.



    Click image for larger version. 

Name:	Form sample.png 
Views:	15 
Size:	56.7 KB 
ID:	14241Click image for larger version. 

Name:	relationships.png 
Views:	15 
Size:	11.4 KB 
ID:	14242

    What I would like to do would be to have a command button next to the plant combo box that brings up a form that allows me to select all of the other plants or some of the other plants (multiselect listboxes I believe would work) and copy all the data in the current subform for the current plant to these other plants if need be. I've figured I need to create some sort of command button or append query but my knowledge is rather basic when it comes to append queries and VBA, so if anyone knows of any resources or examples of this they can send me to that would be awesome. The general idea I have in my head is that I need to loop through the plant values in a list box add each value to the table and append all of the current subform values to the same table as well until all of the values in the list box have been run through. Or if there is a better approach to this I'd be grateful.

    Thanks,

  2. #2
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows XP Access 2003
    Join Date
    Aug 2013
    Posts
    7,862
    Here is some code to loop through a list box. Once you have one of the selected items, you need to do something with it. Do something within the loop. This is air code so double check it.

    Code:
    dim varEmail as variant
     dim strAnswer as string
    
     if me.lstSelection.count = 0 then
     exit sub
     else
    
     for each varEmail in me.lstSelection.itemselection
    
     strAnswer = strAnswer & me.lstSelection.column (0, varEmail)
    
     next varEmail
    
     end if

  3. #3
    illicited is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Mar 2013
    Posts
    28
    Thank you ItsMe. I'll look into that for command button code; now to figure out the append query part.

  4. #4
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows XP Access 2003
    Join Date
    Aug 2013
    Posts
    7,862
    Try adding a

    debug.print stranswer

    or

    Msgbox strAnswer

    Once you validate the answer you are getting, you can move to the next step. Get the control name and column correct first.

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

Similar Threads

  1. Repeating same Data to the next/new Record
    By djclntn in forum Forms
    Replies: 8
    Last Post: 11-07-2012, 08:09 AM
  2. Data in subform records repeating
    By skatiekat in forum Forms
    Replies: 2
    Last Post: 11-01-2012, 12:50 PM
  3. Replies: 1
    Last Post: 01-24-2012, 01:13 AM
  4. Replies: 1
    Last Post: 01-23-2012, 11:54 PM
  5. Repeating data in a field for a new record
    By NOTLguy in forum Forms
    Replies: 3
    Last Post: 10-29-2010, 07:27 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