Forms :: Move Selected Items To And From Listboxes?
Dec 11, 2013
I have 2 Listboxes the first list is based on a query I need to select items from this box or part of each item and move to another listbox. the items in the second listbox will be used in a report. I have previously posted on another forum with no real luck fyi. the query is put straight in the RowSource.
Move Selected Items Between Listbox1 (listEmp) and listbox2 (listAllocated). the items moved from listEmp must be removed from listEmp when moved to list allocated and vice versa.
Overview:
listEmp is my first listbox and currently has the query in it's rowsource SELECT e.* FROM qryEmp AS e; it has 7 columns but only 6 are showing (Column 1 is hidden) and it is currently bound to 1
listAllocated has only 4 columns (can be changed) i only need the first 4 columns from the first list. currently it has no row source and the row source type is set to Value it is also bound to 1
I did find some code that does not do what I need but is closer than anything that I have found so far. It seems like it is copying the Selected Items from Column 1 and pasting it in the second listbox. but it is pasting them all in a row and not in individual columns below is the code. I will post a screen shot in 2 posts time.
Code: Private Sub cmdCopyItem_Click() CopySelected Me End Sub
I have a form with a listbox in which users should be able to move the items up and down. The listbox has 4 columns and multiple selection is enabled.
For a NON multiselect box I have it working, and also for a multiple selection box but in that case it works only for one row at a time.
For a NON multiselect listbox:
Code: cmdDown_Click() Dim i As Integer Dim t1 As String, t2 As String, t3 As String, t4 As String i = selectie.ListIndex t1 = Nz(selectie.Column(0, i)) t2 = Nz(selectie.Column(1, i))
[Code] ....
You can select an item and then press "Down" as many times as you want to put the items as "down" in the list as you want it to be.
Multiselect listbox
This code also works for a multipleselection listbox when one item is selected, however, after you press "down" the item is still selected (highlighted) as the code reselects is (last line) BUT the value of selectie.listindex apparently is set to "-1".
Pressing "Down" again generates an error (i = -1). I can evade the error by adding "if selectie.listindex <=0 then exit sub", but that doens't fix the problem that the only way I can manage to reset the listindex to the new "position" of the item is to click on it again and THEN press "Down".
To fix this and be able to press "down" multiple times listindex should be set to the new value.
Adding a "me.selectie.listindex = i -1" doens't work (error), it seems like this value is readonly.
I can't find a way to "simulate" a mousepressed selection and really set the listindex.
The other problem is of course that this code doens't support moving multiple items at once: listindex points to the last selected item, but only one.
So, I tried another piece of code to move multiple items, not using listindex (since that resets to -1), but I run into another problem
Code: Private Sub cmdDown_Click() Dim var As Variant Dim i As Integer Dim n As Integer Dim t1 As String, t2 As String, t3 As String, t4 As String n = Me.selectie.ItemsSelected.Count
[Code] ....
The problem with this is: I can select multiple items and press "Down", but the problem now is that the selection is lost as soon as the code removes the first item, and the 2nd loop skips the if selected(i) = true (nothing is selected anymore). The me.selectie.selected(i+1) = true doens't work since that would only reselect the first item after moving it.
The code "forgets" which items were selected and moves only one item...So I guess I need to put the indexnumbers in memory while moving the items.
I have been searching a lot, but can only find VB-solutions. In VB it's a lot simpeler using f.e. the .list property of a listbox, which is not available in MSAccess
The solution I'm thinking about is:
- set an array with the numbers of selected items - put indexnumbers of the selected items in the array (f.e. 3 and 4) - move items based on the indexnumers in the array - when moving an item update the indexnumber in the array (3>4, 4>5) - after moving all items reset the selection based on the array
It occurred to me then if I'm going to use an array anyway, I might as well load all items in an array, do the "resorting" and the reload the items in the list from the array. Might be more straightforward?
Btw...It seems VB has a simple solution to moving items: listbox.list(i) = listbox.list(i+1) or something like that moves an item. Even Excel seems to have this property but not MS Access!
I've designed access form with one listbox and added 'up' and 'down' buttons to move up and down the selected item in the listbox. i.e from its selected position to one item up when 'up' button clicked and same as one item down when down button is clicked. Any VBA code will do this functionality?
I'm creating an employee audit database, and, in the audit form, the user (ie. supervisor) can select a number of items from a listbox. Each item selected corresponds to an error that the employee has made, and, as such, the employee's Audit Score has two points deducted for each item that is selected.
Incidentally, there are other, solitary elements to the form, but this particular listbox houses a collection of items that are related under a single category.
The score is displayed at the bottom of the form, and it needs to update in real-time.
The problems that I am encountering are that I am unable to count the number of items selected and then I am unable to multiply that count by 2 (the point-value of each item on the list.)
How would I create a relationship between a subform and a coverage field such that when i multi select items in the subform, it will show what items are selected in the coverage field as in the example.
I'm trying to create a right-click event on a listbox that will copy selected listbox item(s) to a temp table. So far, I've got this code to acknowledge the right click:
Code: Private Sub List0_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single) If Button = acRightButton Then MsgBox "You pressed the right button." End If End Sub
Problem is the selected item on the list box doesn't move until after the mouse down event so whatever code I would run would involve the wrong record(s).
I'm using Access 2000 and 2003. How to get the the correct record selected on mouse down, or point me to a working example of right-click functionality on a listbox.
hi i apologize if this question has been answered before. i have looked at numerous others in the 'listbox' search box, but not had any success in adapting the answers to what i need.
i have a form A with a listbox of 1,400 rows
i then select maybe the 10th row down on the listbox, and
a new form B opens with information pertaining to the listbox row selected form A changes its visible value from true to false
i do my editing on form B
now what i would like to do is, on form B click a next button and for
form B to close form A to be visible again, and the next row (11th) on the list box be highlighted form B to open again but with pertaining to the next listbox row (11th) selected form A to not be visible
As my title states, that is my problem! I'm building search criteria from a form and have multiple list boxes... I want to be able to determine whether or not a list box has items selected or not. I have tried as many things as i knew how to with no luck...
Also, i searched the forum but could not find what i was looking for -_-
Hi all, greate site and i have been able to solve most problems by using the search box although this problem is doing my head in...!!
I have a db that records project numbers and their details. I am using a listbox to allow a user to multiselect Project Involvements Tasks(ie Documentation, Build etc) against a project number.
I am able to read the selections into a separtate table with two columns which is structured as:
as you can see I dont have a problem getting the Itemsselected into a table... the problem that i am having is getting them out again when the record is displayed - ie marking them as itemsselected.
I believe that the event would be onCurrent which would loop through this table pick up the project number and recorded invovements and mark them as selected in the listbox. if there is no invovement then the listbox would show no selections.
I am using this code to read the selections in
=========================== 'Records project involvements against project Public Function AddInvolvements(ctlRef As ListBox) As String On Error GoTo Err_AddInvolvements_Click
Dim i As Variant Dim dbs As DAO.Database Dim rs As DAO.Recordset Dim qd As DAO.QueryDef Dim strDelete As String
Set dbs = CurrentDb Set qd = dbs.QueryDefs!qInvolvement Set rs = qd.OpenRecordset
'Delete records where project number exists against an invovelment incase of involvement changes strDelete = "Delete Project_Involvement.ProjectNo " & _ "FROM Project_Involvement " & _ "WHERE (((Project_Involvement.ProjectNo)=[Forms]![Add_Project_Details]![ProjectNo]));"
For Each i In ctlRef.ItemsSelected rs.AddNew rs!InvolvementType = ctlRef.ItemData(i) rs!ProjectNo = Me.ProjectNo.Value rs.Update Next i Set rs = Nothing Set qd = Nothing
Exit_AddInvolvements_Click: Exit Function
Err_AddInvolvements_Click: Select Case Err.Number Case 3022 'ignore duplicate keys Resume Next Case Else MsgBox Err.Number & "-" & Err.Description Resume Exit_AddInvolvements_Click End Select
End Function ===================================
Any help would be much appreciated - also thanks to Pat Hartman for his excellent examples esp http://www.access-programmers.co.uk/forums/showthread.php?s=&threadid=54924
Can some one tell me why, on the attached database example, I can select multiple items from list boxes "TipoCliente" and "FaixaEt" through "frmClientes" form but they are not passed forward to table "tblClientes" ?
Try to onpen attached database example and use form "fmrClientes" and select multiple items at "TipoCliente" and "FaixaEt" list boxes by entering them with mouse click and Ctrl key pressed . Select also single item from "NivEns" Combobox and write anything on "Nome" and "Apelido" fields .
Go to the table "tblClientes" and you can see text fields "Nome" and "Apelido" and also the item "NivEns" from Combobox "NivEns" are all there but not the items you selected from "TipoCliente" and "FaixaEt" list boxes .
I want to use an array to store data from a list box into a variable. I want it to be able to store one value, or multiple values, depending on what is selected.
Main problem: this list box feeds off a table which has employee names and their e-mails. The list box itself only shows the names, and when I select what I want the array to store is their e-mails, not their names.
Code: Dim strNames As String Dim varItem As Variant Dim intCount As Integer For Each varItem In Me.lstNames.ItemsSelected intCount = intCount + 1 Select Case Len(strNames)
[Code] ....
That code successfully displays the item I selected, but only displays the name. I need to make it look in the table and get me column #2. I also want it to be able to select more than one item at a time.
I have the code below and am trying to have a form allow Text Box to become visible based on selected items from a List box. Why I am getting the error listed?
Compile Error: Invalid Qualifier
Code: Private Sub specific_opt_Click() Dim users As Control Dim ctrler As String Dim xx As Long If Me.specific_opt = True Then GoTo 169
I am new to Access and I have get to where the users can make selections in the listboxes, but then I need to save the selection in a query or table to save thier changes.
What i wish to do: list activities in a continuous form, and in one column display for each row a listbox which rowsource query is based on another column value from the same row.
I have to admit that the best thing for me would be to be able to create through vba a continuous form... is that possible?
Hopefully somebody can help me on this one. I searched the whole internet and access forums, but I didn't find the exact solution for my problem.
I've got a table with students, a table attendance, where I now only save the students who are absent, but I would like to save also the students who are PRESENT (at the same time). I've got a combobox where I filter the Class, which then updates a listbox with the students from that class. What I do now is select the students from the listbox and then press a save button and it saves the records to the table absence with STATUS: ABSENT.
I would like to save the NON selected students also in that table, but with PRESENT in the column STATUS.
I thought of making another listbox next to it, where after selecting the absent students, they wil apear and disappear in the PRESENT table so I can store all the information. But the only problem is that I can find this solution when the listbox is populated by a list of values instead by a table or query. And the other solution is to store the temporary data into 2 different tables, but that's not working for me because it's a multi user database and everything will be messed up.
Hope that someone can help me, I will be very happy.
I would like passing values from first form until third form.
In the first form I have a list box after selecting items (For each selected item in first form I have 4 values) and pressing button (or right click of mouse) the second form will be open, then in the second form I have 2 option (inserting, deleting), when I select inserting or deleting in the second form, third form will be open, in the third form there is a "OK" button, when I press that, passed values from first form will be used for inserting or deleting records to the table.
I have an Equipment Form with a Supplier subform. The Supplier subform also has a subform, Equipment Pricing Records.
I have the ability to change the Supplier via a combo box, but Equipment Pricing Records become orphaned.
What I would like to do is when a Supplier is about to be changed, for the user to have the option to either a) delete the sub records, or b) the sub records to move across to the new Supplier.
I know I will need to use the after update event once the delete or move decision is made, but I can�t think how to identify the records and then either delete or move them to the new Supplier ID.
The EquipmentID will never change.
Fields are;
EQUIPMENT form; EquipmentID
SUPPLIER form; SupplierID EquipmentIDFK
PRICING RECORD form; PricingRecordID SupplierIDFK EquipmentIDFK
I have a subform that I use to scan in products using a barcode reader, when the item scans it moves to the quantity (Qty) field where I have this code:
Code: Private Sub Qty_GotFocus() Qty.Value = 1 DoCmd.GoToRecord , , acNewRec txtOrderNo.SetFocus End Sub
I am simply trying to set the Qty value to 1 and move onto the next record ready to scan another product in.
And trantype look-up field containing transaction type debit or credit.
Here in this form i want when i select debit transaction type then control move to the Damount and on pressing Enter key Camount skip and control move on Description, and same like this when i choose transaction type Credit then Damount skip away and control move on Camount field and next to description, and access doesn't ask for enter value in Damount.
I have a main form that has 2 sub forms on it - one below the other.
Because I did not like this layout I created a tabbed form on the bottom of the main form (2 tabs) and would now like to move each sub form onto each of the tabbed forms.