Results 1 to 9 of 9
  1. #1
    4 Star Lounger
    Join Date
    Jan 2001
    Location
    Houston, Texas, USA
    Posts
    432
    Thanks
    0
    Thanked 0 Times in 0 Posts

    select several items from a pulldown down list (Outlook 98,2K & Access 97)

    I use the following to open up a drop down list with all the names. I need to be able to select several of them at one time and move them to a second box. From this second box I hope to store them in a different database. Either in a memo box or a list box.

    Any ideas?


    Function Item_Open()
    '-=-=-=-=-=-=-=-=-=-
    Dim rst1
    Dim dao
    Dim wks
    Dim db
    Dim nms
    Dim fld
    Dim itms
    Dim itm
    Dim strAccessDir
    Dim objAccess
    Dim CategoryArray(99, 2)
    Dim CustomerArray(99, 2)

    'Pick up path to Access database directory from Access SysCmd function
    Set objAccess = Item.Application.CreateObject("Access.Application" )
    strDBName = ("remitsremit10.mdb")
    'MsgBox "DBName: " & strDBName
    objAccess.Quit

    'Set up reference to Access database
    Set dao = Application.CreateObject("DAO.DBEngine.36")
    Set wks = dao.Workspaces(0)
    Set db = wks.OpenDatabase(strDBName)

    '-=-=-=-=-=-=-=-=-=-=-

    '-=-=-=-=-=-=-=-=-=-=-
    'Gift2U Area Code 1
    'Retrieve Category info from table
    '-=-=-=-=-=-=-=-=-=-=-
    Set rst2 = db.OpenRecordset("Areas")
    Set ctl = Item.GetInspector.ModifiedFormPages("Message").Con trols("cboarea1")
    'The above is the name of the form and not the name of the tab
    ctl.ColumnCount = 2
    ctl.ColumnWidths = "50; 120 pt"

    'Assign Access data to an array of 2 columns and 2000 rows
    CategoryArray(99, 2) = rst2.GetRows(2000)
    ctl.Column() = CategoryArray(99, 2)
    '-=-=-=-=-=-=

  2. #2
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: select several items from a pulldown down list (Outlook 98,2K & Access

    Where does Outlook come into this? Where are you trying to move the list from, Outlook or Access? When you say store them in a different database, are you talking about a database file (an MDB) or a different table within the same database file? You don't store anything in a memo box or list box, you store it in table fields. Controls, in either Access or any other application are just ways of presenting the data.

    If this is a purely Access question, it should be posted in the Access board.
    Charlotte

  3. #3
    4 Star Lounger
    Join Date
    Jan 2001
    Location
    Houston, Texas, USA
    Posts
    432
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: select several items from a pulldown down list (Outlook 98,2K & Access

    I have the first part of it figured out. I created a list box in my Outlook form and went into the Advance properties and selected the multi list option. So now I am able to selected several names on the list box on the left side.

    My next problem now is how to get the selected names copyed/moved to the list box on the right side. Then after they are moved I will save it to my access. I am trying this code now. I'm fairly sure it will not work but it is a start for me.

    Private Sub_command1_click()
    Dim intloopIndex
    For intloopIndex = 0 to list1.listcount -1
    If list1.selected(intloopindex) then
    list2.additem list1list(intloopindex)
    End if
    Next intloopindex
    End sub

  4. #4
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: select several items from a pulldown down list (Outlook 98,2K & Access

    You still haven't explained what it is you're trying to accomplish with these listboxes and Outlook/Access. However, you should be able to loop through the items in the first listbox and for each one that's selected, add that value to the second listbox using your code. Perhaps if you explain more about the whole thing, someone can help you take it further.
    Charlotte

  5. #5
    4 Star Lounger
    Join Date
    Jan 2001
    Location
    Houston, Texas, USA
    Posts
    432
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: select several items from a pulldown down list (Outlook 98,2K & Access

    In the listbox to the lift is a database list that contains all the "Areas" where our clients are located. When we process an order we select all the Areas that we want to process. Thus, the list on the lift could have 1 or 100 area selected. Once they are selected , we want to use a command button and move the information to the right side list box. From there the selections are moved into a database.

    I am able to select the different areas on the left side. Now I need to move them to the right side (it also serves as a visual step for the user to make sure they got the right ones) and save the information into a field in the database.

  6. #6
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: select several items from a pulldown down list (Outlook 98,2K & Access

    So have you tried looping throught the items in the first list and using AddItem to add each one that has a Selected = True to the second list?
    Charlotte

  7. #7
    4 Star Lounger
    Join Date
    Jan 2001
    Location
    Houston, Texas, USA
    Posts
    432
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: select several items from a pulldown down list (Outlook 98,2K & Access

    That is the part I am having problems with. I can select the item on the left. But how do I make a button to move them to the right list. I keep getting "Syntex error - at DO WHILE line

    '-=-=-=-=-=-
    'Call Move Selected
    Sub cmdMoveit_click()
    If rstlist1.SelCount = 0 Then MsgBox "No items selected. Cannot continue.", 16, "Error: No Selected Items": Exit Sub
    For x = 0 To rstlist1.ListCount - 1
    If rstlist11.Selected(x) = True Then 'Found a selected item
    list2.AddItem rstlist1.List(x) 'Add to second list
    End if
    DO while
    Next x
    End if
    'cmdClear1_Click
    End Sub

  8. #8
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: select several items from a pulldown down list (Outlook 98,2K & Access

    You're getting a syntax error there because you haven't given it a condition to evaluate. What are you trying to Do While? And what is rstList1? If it's a listbox, then what are you trying to do here:

    If rstlist11.Selected(x) = True Then
    Charlotte

  9. #9
    4 Star Lounger
    Join Date
    Jan 2001
    Location
    Houston, Texas, USA
    Posts
    432
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: select several items from a pulldown down list (Outlook 98,2K & Access

    I have two listbox's:

    1. I use the first listbox to list all the names in the table. I want to be able to select several names at one time and with with a button move them to a second listbox.

    '-=-=-=-=-=-=-=-=-=-=-
    'Area Code
    'Retrieve Category info from table
    '-=-=-=-=-=-=-=-=-=-=-
    Set rstlist1 = db.OpenRecordset("Areas")
    Set ctl = Item.GetInspector.ModifiedFormPages("Message").Con trols("cbolist1")
    'The above is the name of the form and not the name of the tab
    ctl.ColumnCount = 1
    ctl.ColumnWidths = "6; 6pt" '50; 120 pt

    'Assign Access data to an array of 2 columns and 2000 rows
    CategoryArray(99, 1) = rstlist1.GetRows(2000)
    ctl.Column() = CategoryArray(99, 1)
    '-=-=-=-=-=-=

    2. I then wanted to use this(or any) code to move the selected names to the second listbox.

    '-=-=-=-=-=-
    'Copy Selected
    Sub cmdMoveit_click()
    If rstlist1.SelCount = 0 Then MsgBox "No items selected. Cannot continue.", 16, "Error: No Selected Items": Exit Sub
    For x = 0 To rstlist1.ListCount - 1
    If rstlist11.Selected(x) = True Then 'Found a selected item
    list2.AddItem rstlist1.List(x) 'Add to second list
    End if
    DO while
    Next x
    End if
    'cmdClear1_Click
    End Sub

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •