Multiple Select Listbox

Oct 6, 2006

Hi,
I tried putting a multiple select listbox in my access form but I cant put values in it. I want to put values of a table (i.e a field in the table) in the list.

I have selected the microsoft forms 2.0 listbox..
1> How can I put values in it?
2> Is there a way to make the access listbox a multiselect one?

Thanks

View Replies


ADVERTISEMENT

Modules & VBA :: Listbox Setup With Option To Select Multiple Items

Jan 7, 2015

I am trying to set up a listbox with an option to select multiple items (I have done this and tested it with debug.print and it seems to work). I am then building a filter statement with VBA. I want to then use a button to add this statement to the filter in a subform with (a datasheet design), and then requery it.

My code below seems to be working in part. But I am getting all the items at times. Seems to work consistenly when selecting one item only, but I can't see anything wrong with my 'OR' statements when I debug.print.

Private Sub Command176_Click()
Dim i As Integer
Dim strFilter As String
Dim blnFirst As Boolean
i = 0
If Me.List163.ItemsSelected.Count = 0 Then

[Code] .....

View 3 Replies View Related

Forms :: Dynamic Row Source For Listbox From Multi-select Listbox

Jun 10, 2015

I am using the selections made of the form to generate a query for the user.

I have a CITIES listbox that is populated with values from a stored query.

I would like to make it multi-select and populate a LOCATIONS list box and a NAMES list box based upon the CITIES that are selected.

I have the locations currently populated from a stored query that reads the City selection from the Form. It looks like this

Code:

SELECT DISTINCT (t_location.LOCATION) AS Expr1
FROM t_location INNER JOIN t_asset_master ON t_location.LOCATION_PHY_ID = t_asset_master.LOCATION
WHERE (((t_location.CITY)=[Forms]![MasterQueryGenerator]![CityList]));

I also want multi-select so that is you can un-select all and get the results for all cities.

Here is my half thought approach.

Code:

Private Sub CityList_AfterUpdate()
'Dim LocQryStr As String
'Dim r As Integer
'Dim ctl9 As Control
'LocQryStr = "SELECT DISTINCT (t_location.LOCATION) " & _

[Code] ...

I intended to have the variable LocQryStr as the row source but I abandoned the idea of having multi-select when I saw that .Selected(I) never returned true. Its like the values aren't read in this subroutine.

View 5 Replies View Related

Select Values In Multi Select Listbox

Aug 19, 2005

i have a multiselect listbox in my form.
The multiselectlistbox contains the names of different persons from tblUsers.
it's allready possible to write the id's of the names to another table (tblPresent).

But what I can't manage to do is re-select the values in another multiselect listbox. This multiselectlistbox is located on my editform.
I can display the values using a valuelistbox, but i need to see the non-selected items too..

hope someone can help me out

View 1 Replies View Related

Select All Listbox AND Update Listbox

Jun 17, 2005

Hello,

I've got this multiple select listbox which writes data into a textbox:

Private Sub List2_AfterUpdate()

Dim Cursisten As String
Dim ctl As Control
Dim Itm As Variant

Set ctl = Me.List2

For Each Itm In ctl.ItemsSelected
If Len(Cursisten) = 0 Then
Cursisten = ctl.ItemData(Itm)
Else
Cursisten = Cursisten & "," & ctl.ItemData(Itm)
End If
Next Itm
Me.txtCursisten = Cursisten

End Sub

And I've got a SELECT ALL button to select all records in the listbox:

Private Sub cmdSelectAll_Click()
On Error GoTo Err_cmdSelectAll_Click

Dim i As Integer

If cmdSelectAll.Caption = "Alles Selecteren" Then
For i = 0 To Me.List2.ListCount
Me.List2.Selected(i) = True
Next i
cmdSelectAll.Caption = "Alles De-Selecteren"
Else
For i = 0 To Me.List2.ListCount
Me.List2.Selected(i) = False
Next i
cmdSelectAll.Caption = "Alles Selecteren"

End If

Exit_cmdSelectAll_Click:
Exit Sub

Err_cmdSelectAll_Click:
MsgBox Err.Description
Resume Exit_cmdSelectAll_Click

End Sub

The only thing is that when I use the SELECT ALL button, the function List2_Afterupdate doesn't work anymore. There must be a simple solution but I just can't figure it out. Can anyone please help me?

Tnx a lot!

View 13 Replies View Related

Listbox Select ALL

Mar 29, 2006

I have the following code where C is the listbox control

wCount = C.ListCount
Screen.ActiveForm.Painting = False
For wCounter = 0 To wCount
.Selected(wCounter) = True
Next
Screen.ActiveForm.Painting = True

This works fine - but is slow if a listbox has lots of records.

Is there a quicker way to select all items in a listbox?

(Both simple and extended - maybe this occasion will never happen that someone wants to select so many items that speed becaomes a factor, but I would like to have this covered just in case)

Thanks - Paul

View 2 Replies View Related

Select A Row From A Listbox

Jun 24, 2005

Could someone please help me do the following.

When I open my main form I would like the focus set on a listbox and the first row being selected.

I can get the focus set Me.List39.SetFocus but how do I select the first row?

View 5 Replies View Related

I Just Want To Select An Item In A Listbox!!

May 9, 2005

Hi Everyone!

I'm having problems and am frustrated as usual ;)

I'm trying to select a specific row in a listbox in the OnKeyDown event on my form. Basically, while in a subform, I want the enter key to move the focus to the list box, specifically to row After the last selected.

Here's an example of the code I thought would work:

Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
Dim ItemNumber As Integer

ItemNumber = Forms![Product Inventory System]![InvList3] + 1

If KeyCode = vbKeyReturn Then
Forms![Product Inventory System]![InvList3].ItemData(ItemNumber).SetFocus

Else

End If
End Sub

I just started the Atkins diet today, so my sugar and caffiene levels are non-existant. (Seems like an easy excuse, right?)

Can anyone offer any insight into what I'm doing wrong?

Thank you so much!
Ben Bolduc

View 2 Replies View Related

Select All Items In A Listbox

Sep 21, 2005

How to code a "Select all" button to a multi select listbox named lbSeleccionePuerto

View 2 Replies View Related

Select All Items Ina Listbox

Oct 11, 2006

Does anyone know if its possible to select all items (that is turn all items black) in a listbox? thanks

View 1 Replies View Related

ListBox To Select Records... Please Help

Aug 5, 2005

Hello All...

I currently have a ListBox which I am using on a form as a "jump To..." record selector. It has to show 4 values to the users, and so far it has worked quite well. However, I recently added some queries to the footer of the form to help narrow down the data for searches, or if the user wants to see all open data of a certain topic. I'd like to have the ListBox "refresh" and only display the results of the query, but I cannot for the life of me figure out how to do it. The root of the problem seems to be that the initial SQL for the ListBox is selecting values from the under-lying table, and when the filter is applied, it simply doesn't care. When you click on entries that aren't in the filtered dataset, it doesn't error out or anything, and when you click ones that ARE in the filtered dataset, it does work properly... I'm close... How do I filter the listbox as well?

Thanks,

View 4 Replies View Related

Not-So-Easy Select And Deselect In Listbox (For Me At Least)

Sep 29, 2005

I made sure I did a search for this topic before I posted, so please don't flame me.

I'm trying to do something that in theory does not seem hard to do, but for some reason I can't translate it into code. With using a ListBox, I understand how to do a simple "when a value is selected, the remaining values are deselected" code. What I am trying to do is:


When the form is opened, the default selection of the listbox (lbOfficeLocation) is "***All Offices***".

If the user selects any other value (multiple values can be selected), the value "***All Offices***" is deselected.

If the user selects the value "***All Offices***", all other values are deselected.

For some reason or another, I can get (1) & (2) to work, but I cannot get (3) to work. After I make my initial selection that forces the deselection of value "***All Offices***" and highlights any other individual or multiple values, I try to re-select "***All Offices***" and it won't highlight, and will not deselect any of the other selected values.

I have tried multiple ways to code this, from using a For loop, If statement, and even a Select statement (Case 1, Case 2, ...), even using both Click() and AfterUpdate() as the event procedures, and nothing. I don't know how to use a IIF() statement very well, but do I need to use one of those? The code for what I have so far is below:

The name of the Listbox is "lbOfficeLocation".

Private Sub lbOfficeLocation_Click()

Dim holder As Integer

For holder = 0 To lbOfficeLocation.ListCount - 1
If lbOfficeLocation.Selected(holder) = True Then
Me.lbOfficeLocation.Selected(0) = False
End If
Next holder

End Sub


This code is for the deselection of value "***All Offices***" if any other value is selected. Please help me find the code to help with scenerio (3) as listed above, while still maintaining (2).

Thank you in advance, and feel free to ask for any additional info.

View 6 Replies View Related

Programmatically Multi-select Listbox

Jul 19, 2005

hello!
i'm trying to select more than one value in a listbox based on a comma-seperated string in a textbox. it seems to be doing what it's supposed to do, except it's only selecting the last value it loops through. it doesn't seem to remember the others. there's probably an easier way to do this than how i did it, but here is the code:

Code:Dim lst As ListBoxDim lngCount As LongDim strSelection As StringDim strNewSelection As StringDim intLen As IntegerDim lngLen As LongstrNewSelection = ""strSelection = Me.Text19.ValueWhile InStr(1, strSelection, ",") <> 0strSelection = Trim(strSelection)lngLen = Len(strSelection)intLen = InStr(1, strSelection, ",")strNewSelection = Left(strSelection, intLen - 1)Set lst = Me!List0lst.RowSource = lst.RowSourceFor lngCount = 0 To lst.ListCount - 1 If lst.Column(0, lngCount) = strNewSelection Then lst.Selected(lngCount) = True Exit For End IfNext lngCount strSelection = Right(strSelection, lngLen - intLen)Wend

any bright ideas???
thanks,
*j

View 3 Replies View Related

Modules & VBA :: How To Select Item From A Listbox

Jul 29, 2013

At the moment I have a query that returns a result based on what's selected in a combobox.

SELECT ComponentT.ComponentType AS ComponentType
FROM ComponentT
WHERE (((ComponentT.TotalComponent) Like [Forms]![DeviceF]![D_ComponentNameCmb] & "*"));

Instead of this I want to rewrite the query to return a result based on what the user has selected in a list box of items. How would this query look. Would I need to increment it in a loop checking all entries into the list box as it can vary in size and if so how?

I tried changing the last line to WHERE (((ComponentT.TotalComponent) Like [Forms]![DeviceF]![D_OutputLsb].[ItemsSelected] & "*")); which returned a result just not the right one. Is there something wrong with the syntax?

View 4 Replies View Related

Filter Query By Multi Select Listbox

Jul 27, 2006

Dear All,

I am just starting out in Access Development. I have a database that runs a logistics department. This was working fine until the users wanted a little more tweaking.

The report prints out the vehicles with all corresponding drops. This comes out all on sheet.

Is there a way that I can create a form to filter the report via a multi select listbox and print each drop selected on a seperate sheet of paper.

I am using Access 2003

Many thanks for any help or source code given

View 3 Replies View Related

Select And Print An Excel Spreadsheet From ListBox

Sep 16, 2005

Hello,
Propably I am asking too much but know that Access and VBA can almost do anything.
Is it possible to add a list box on a form to list the spreasheet in a excel file and by clicking on the select record make a print only of that specific spreadsheet?

Thanks.

View 6 Replies View Related

Forms :: Select / Delete A Record From Listbox

Aug 14, 2013

How to do a 'Delete from ListBox' . My listbox is populated, but I want to be able to put a button on the form, select a record from the listbox and press the button to delete that record from the list.

I should add that this is an unbound listbox so it needs to be removed from the listbox and the table that is populating it.

Listbox is List22 the table that populates it is 'tblShootingTasks'

View 7 Replies View Related

Hitting Ctrl To Multi Select From ListBox

Jun 25, 2014

I am having a form that has a listbox, which brings up a lot of records, and the user may choose multiple records, but when user wants to scroll down the page to multi select, he cant do it with the ctrl keyboard button, when he press ctrl the page jumps back up, is there any workaround for that?

View 14 Replies View Related

Multi-select Listbox And Date Range

Nov 26, 2014

I recently have ontained some responsibilies from a coworker who has left the company.

I have frmEdgeReport which uses ratio buttons to populate the

multiselect listbox .. this all works.. now i need to add date ranges and

Everything I do seems to screw up what I already have working..

I have added two textboxes - txtStartDate and txtEndDate.

Currently I am getting error when i put the SELECT statement in its own query that says "Invalid SQL Statement; expected 'DELETE', 'INSERT', 'PROCEDURE', 'SELECT', OR 'UPDATE'."

and when I just run my form I am getting an error that says "Error 3142 - Characters found after end of SQL statement"

this is what i have so far :

Private Sub SetReport()
On Error GoTo Err_Handler
'Purpose: Open the report filtered to the items selected in the list box.
Dim varItem As Variant 'Selected items
Dim strWhere As String 'String to use as WhereCondition
Dim strDescrip As String 'Description of WhereCondition
Dim lngLen As Long 'Length of string

[Code] .....

View 1 Replies View Related

Modules & VBA :: Get Other Than Bound Column From Multi-select Listbox

Feb 6, 2015

I have two listboxes. One for Activities and the other for Organizations.

I set the Org listbox to be multi-select so I could run a loop on that listbox to join multiple Orgs to a single Activity. That part works well.

To do so, I am using the bound column (which is the pkey value) from the multi select listbox, and on the single select listbox I'm using the ListboxName.value to gather the pkey for the "1" side of this 1:Many series of inserts.

Now... I want to use one of the other-than-bound-column value from the multi-select listbox, but I don't know how. When setting a value I only know of the use of :

Code:
ListBoxOrganizations.ItemData(varItem)

and I don't know how to do the equivalent of

Code:
ListBoxOrganizations.ItemData(varItem's column(2).value)

yes, I just made that up, but I hope you get the point. Meaning, as the loop cruises the ItemsSelected on the multiselect I'd like to use other than the bound column when setting variables.

I've tried using the column property to then cruise to the proper record in the listbox, e.g. :

[code]
txtCollaborationDesc = "Collaborate " & ListBoxOrganizations.Column(2, varItem) & " with " & listboxActivities.Column(2)
[code]

But this seems to return the column(2) value of the first record loaded into the list box, as if the varItem piece is being ignored. I believe the loop is working properly, as when the inserts are happening correctly with the bound column of the multi-select list is correctly present as an Fkey in the resulting child records.

I just can't get any other column's value for some reason.

MS Access 2010 and this is an accdb.

View 3 Replies View Related

Modules & VBA :: Pass Parameters From Multi-select Listbox?

Sep 24, 2014

1. I have created a parameter query in access 2010. This parameter is on only one field.

2. I have created a multi-select list box in a form so that users can select one of more items.

I want to pass the selected items as parameters to the save access query.

View 1 Replies View Related

Modules & VBA :: How To Process A Select Query Using Listbox Value As Where Variable

May 6, 2015

I am using Access 2013. I have the ability to pull a selection from a listbox. I can create a Select Sql string using that variable

sql As String, strCompany As String, strWhere As String
strCompany = strCompany & Me.lstResource.Column(0, varItem)
strWhere = "[Company name]=" & "'" & strCompany & "'"
sql = "select * FROM tblResources WHERE " & strWhere

From here I have trouble. I see lots of examples to run an active query but not much on a select query. I have tried a number of things with no success. How to use this select statement to actually run against an existing access table? I am not putting it into a form or report at this time, just running the query to check results.

View 1 Replies View Related

Forms :: Listbox To Select Record In Read Only Mode?

May 7, 2014

I have a form which uses a listbox to display a given record but when a user without edit rights opens the form in read only mode

Code:

DoCmd.OpenForm stDocName, , , stLinkCriteria, acFormreadOnly

The user is unable to use the listbox to select a record to view.

I have also tried opening the form in edit mode (acFormedit) and then setting the allowedits etc. to False

Code:
Me.Form.AllowAdditions = False
Me.Form.AllowDeletions = False
Me.Form.AllowEdits = False

But this didn't work either.

View 3 Replies View Related

Reports :: Filter Report By Multi Select Listbox

Oct 10, 2014

I'm using pbauldy's code to filter a report by a multi-select listbox. The only issue is..how do I include more (7 to be exact) listboxes to the code? It seems the OpenReport vba is only allowing 1 where clause?

Code:
Dim strWhere As String
Dim ctl As Control
Dim varItem As Variant
'add selected values to string
Set ctl = Me.VP_ListBox

[Code] .....

View 7 Replies View Related

Forms :: Selecting Query Parameters From A Listbox - Select All

Aug 26, 2013

I've got a code that allows me to select one or many names from a listbox on a form and return data relevant to the name(s) selected from a query. The following code is triggered by a button on the form...

Private Sub Toggle4_Click()
'Set it all up for CSM selection
Dim db As DAO.Database
Dim qdf As DAO.QueryDef
Dim varItem As Variant
Dim strCriteria As String
Dim strSQL As String

[code]....

(Toggle 10 goes to the code for the second listbox which has the same code with different tables refered to giving two selections in the query.)

What I want to do is replace the "warning if nothing found" with a code to show data against all the names in the list box if nothing is selected in the listbox.

View 13 Replies View Related

Forms :: Listbox Bound To Query - Select Only One Record

May 12, 2014

I have a list box bound to a query. If the list box retrieves two records, I am not able to select only one of them. If I click, it gets both records selected ( highlighted ). Is there any way I can select only one record?

View 8 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved