Page 1 of 3 123 LastLast
Results 1 to 15 of 36
  1. #1
    Moridan is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    Apr 2013
    Posts
    60

    Question Multiple choice selection

    Greetings all,

    Using 2007 for a project at work. Here is what I have:
    - Set up of tables that flow Division -> Branch - > Missions - > Projects -> Updates


    - Form that inputs worker updates into the Update table. This is working just fine.
    - Form that I use for Management to output the Update information based upon a DATE RANGE and the DIVISION or BRANCHES.
    - There are multiple Branches in the Division
    - I have the form feeding a Query that has a criteria for the input date. This is also working fine.

    *** My problem is in selecting the Branch. I have a combo box that works just fine but can only select a single Branch. But I need the ability to select multiple Branches. I have tried a list box but it wont feed the query properly for some reason. I have tried everything I can think of to make this work, but am out of ideas.

    Any assistance would be greatly appreciated. Thank you!

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    Moridan is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    Apr 2013
    Posts
    60
    Thanks Baldy. I guess part of my problem is that I am very new to Access. I understand that what you linked was VB code, but I havent a clue how/where to add this. There are so many variables in this that I am not sure what I can change and what has to remain.

    I really appreciate your help!

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    This should get you started:

    http://www.baldyweb.com/FirstVBA.htm
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  5. #5
    Moridan is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    Apr 2013
    Posts
    60
    Ok, I think a little light is trickling into my brain. Will the same code work for a combo box, or only a list box?

    Thanks!

  6. #6
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    I've never used the combo box bound to a multi-value field, so I'm not sure how those operate. My gut is that code will not work for those, but I'm not sure.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  7. #7
    Moridan is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    Apr 2013
    Posts
    60
    Ok, finally back to this project. I transferred the code into my database but when I click the button to open the report a window pops up asking "Enter Parameter Value" on the top, the name of the selection that was made from the list box below that, and then a data entry space below that. If I type in the same data that was in list box it runs the report as it should. But why is it asking for this information again? The only thing I could think of was that somehow I didnt correctly transfer this line:

    'open the report, restricted to the selected items
    DoCmd.OpenReport "rptEmployees", acPreview, , "EmpID IN(" & strWhere & ")"

    I replaced prtEmployees with the name of my report that is running and EmpID with the name of the field on the table where the selection is coming from.

    What I dont understand is "acPreview" and the "IN" after "EmpID".

    Any ideas what I am doing wrong? Thanks again for the help!

  8. #8
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    VBA help has info on those. EmpID has to be the name of the field in your data.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  9. #9
    Moridan is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    Apr 2013
    Posts
    60
    Or is my problem with this section:

    Set ctl = Me.lstEmployees
    For Each varItem In ctl.ItemsSelected
    strWhere = strWhere & ctl.ItemData(varItem) & ","

  10. #10
    Moridan is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    Apr 2013
    Posts
    60
    Ahh I was going off the example db and mistyped this statement from the example code on your website:

    'Use this line if your value is text
    'strWhere = strWhere & "'" & ctl.ItemData(varItem) & "',"

    One step closer to getting this done, but that was the major hurdle. Thanks!

  11. #11
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    No problemo!
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  12. #12
    Moridan is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    Apr 2013
    Posts
    60
    Now the last step is to get the report to output in Word. How can I modify the Report line to output this as a Word document?

  13. #13
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    I've never needed to output to Word. Right after the OpenReport line try using OutputTo.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  14. #14
    Moridan is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    Apr 2013
    Posts
    60
    Doing some research on "OutputTo". Are you suggesting I start another DoCmd function on the line below the DoCmd.OpenReport function? I think if I replace the line than I lose the ability to restrict the selected items. I would even be Ok with opening in a pdf format.

  15. #15
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Yes, I'm suggesting another line, for the reason you note. If the report is already opened filtered, then the OutputTo will be filtered.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

Page 1 of 3 123 LastLast
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 3
    Last Post: 03-23-2013, 03:13 PM
  2. Replies: 2
    Last Post: 02-21-2013, 07:47 AM
  3. Multiple Selection wth List Box / Combo Box
    By rkalapura in forum Forms
    Replies: 11
    Last Post: 02-09-2013, 11:02 PM
  4. Replies: 7
    Last Post: 10-16-2012, 06:43 PM
  5. Multiple record selection on list box?
    By looloo in forum Forms
    Replies: 2
    Last Post: 09-22-2011, 05:52 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