Modules & VBA :: Using Array To Store Selected Items In List Box

Apr 10, 2015

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.

View Replies


ADVERTISEMENT

Modules & VBA :: Sum Of Items Selected In A List Box

Sep 10, 2013

how to get the sum of column 2 of a list box total bags is in the second column, i only want the total of bags of the ones selected

I can get the sum of all the boxes but only want highlighted ones

Public Function SumListBox(sForm As String, _
sCtrl As String, iColumn As Integer) As Variant
Dim frm As Form

[Code]....

View 1 Replies View Related

Modules & VBA :: Text Box To Become Visible Based On Selected Items From List Box

Oct 13, 2014

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

[Code] ....

View 8 Replies View Related

Modules & VBA :: Store Entire Query (single Field) In Array And Check Its Values

Mar 12, 2014

Basically, what's the best practice or how do we store a query's value into an array then checking what the max or min value is and how to check if let's say "4" is in the array?

View 1 Replies View Related

Multiple Items Selected From List Box Through A From Not Passes To The Table

Nov 23, 2006

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 .

What is happenig ?

Lots of thanlks

Miguel

View 2 Replies View Related

Queries :: Limit Query To Selected Items In A List Box

Nov 27, 2013

I want to limit the results in a query to the selected items on a list box - how do I do this?

View 4 Replies View Related

Modules & VBA :: Store Path Location Selected By User To A String

Feb 7, 2014

I am using this code

DoCmd.OutputTo acOutputReport, "rptFilter", "Excel97-Excel2003Workbook(*.xls)", strFilename, True, "", , acExportQualityScreen

With the OutputFile set to "" so the user can select the directory on where they want to store the exported template. I'm trying to figure out if I could get the file path and the file name and store it on a string so I could use it for something else.

View 4 Replies View Related

Modules & VBA :: Looping Through All Items In List Box?

Apr 5, 2015

I have managed to amend records based on the user selecting multiple items in a list box by using the following code.

Set db = CurrentDb()
Set rs1 = db.OpenRecordset("Usage", dbOpenDynaset, dbAppendOnly)
Set ctl = [Forms]![frmsearch]![lstSelector]

[Code].....

what I need to do now, is to loop(I think) through and amend all the records in a populate listbox, with no selections, similar to above, but without selection.

View 3 Replies View Related

Modules & VBA :: Items In List Box Deselected When Clicked

Jul 8, 2014

I have added a list box to a form with Single Selection mode on. Its purpose is to improve the interface. It contains items that represent all records. Clicking on the list box causes the form to jump to another record.

The problem is following: if I click on the List Box, it clears the selection and nothing is highlighted but it jumps to correct record. When I use standard record selection buttons, it highlights the correct items.

I read the index of selected item from .ListIndex property because Selected() does not work in a Single Selection mode. However, this is read-only property and I cannot use this to highlight the item back from VBA. But when I use Selected() it is not working. I mean when I click again on the same item it's selected. It's weird. I attached a simple database file with this problem.

The second problem is, when using standard record selection buttons, access iterates through all records and then jump to empty one. That is not like a new record. I don't know which event to use to control this situation. I would like to deselect all items, let user enter the data and re-query the List Box with a new record.

View 3 Replies View Related

Modules & VBA :: List Box Items And Date Range

Jun 17, 2015

I have a multiselect listbox and two date fields (StartDate & EndDate) in an Access form.I am trying to add records to the Table through the form on a button click.I select multiple items from the list box and the date range between the start date and end date will be equal to the items selected from listbox.For each item selected from the list box I need to add a separate record with a date.So the first record will have List box item selected1 and the start date.Next record will have item 2 from list box and date as dateadd("d",startdate,1)And final record will have last item selected from the listbox and date as enddate.

View 5 Replies View Related

Modules & VBA :: MDB File - Deleting Multiple Items In List At Once

May 28, 2014

In appendix is .mdb file with this thema.

Inside you can find one form with listbox (with multi selecting ability).

I use this code :

Dim strSQL As String
Dim i As Variant
With Me.se1
For Each i In .ItemsSelected
SQL = "DELETE '*' FROM [t1] WHERE [id] = " & .ItemData(i) & " ;"
CurrentDb.Execute (SQL)
Next
End With
Me.se1.Requery

Result is this one :
1) If I delete only one item in list, it is ok. I can do it again and again and it is working fine.

BUT

2) If I delete more items in list at once, it is ok - but if I will try to do it again then there is an error because .ItemData(i) value is Null.

View 10 Replies View Related

Modules & VBA :: Inventory - Show List Of Items That Aren't Already In A Table

Jun 19, 2015

I have a list box that allows multiple selections [Inventory]. I also have a combo box that has multiple selections [Shows].

Right now, user selects from list box and from a combo box and clicks a button. On button click, the items from the list box are associated with the PK from the combo and stored in a junction table. This allows me to quickly associate many inventory items to one show.

I realized that there I currently have no way to prevent duplicate Inventory+show records in the junction table besides having a composite key. This would be fine except no records get inserted into the junction table if there's a duplicate entry.

Ideally, I think that the user should select from the combo box [Shows]. This should narrow down what shows up in the list box [Inventory] in a way that Inventory items already associated with the show are not displayed.

If I have 10 Inventory items and Inventory items 1-5 are already associated with Show 1; after I select the combo box, the list box only displays Inventory items 6-10.

Here's the associated code

Option Compare Database
Option Explicit
Private Sub cmdAddRecords_Click()
Dim strSQL As String
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim ctl As Control

[Code] ....

View 13 Replies View Related

Modules & VBA :: Passing Values Of Selected Items From First Form Until Third Form

Aug 12, 2013

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.

View 4 Replies View Related

Modules & VBA :: Combo Box Will Display Specific List Of Items - Form Asking For Parameter

May 5, 2015

I have the below code behind a form so that a combo box will display a specific list of items based on the data in another combo box on my form.

I have two copies of this same form for two different departments. One of the forms works like a dream. However, when I copy that form, change the name, and update the code as pictured below, the form is asking for a parameter FROM MY ORIGINAL FORM and will not requery the combo box. I can't figure out why...there is no reference to the original form in my VBA as you can see below. I tried deleting the form and re-creating it, I tried deleting the code and re-typing it to no avail.

Private Sub cmboType_AfterUpdate()
Me.cmboAction.RowSource = "SELECT tblStatusList.Status FROM tblStatusList WHERE (((tblStatusList.Department)=[forms]![frmInquiryFraud]![cmboType]));"
End Sub

View 4 Replies View Related

Modules & VBA :: Multi-select List Box Items To Pass Into Text Boxes

Oct 16, 2014

I have an access project that I am working on and need to be able to select multiple items from a listbox and have the exact selections appear in a textbox on the same form. I have looked around and have not been able to find any code that works.

I have tried:

Me.user2 = Me.slct_auditor.Column(0, 1)
Me.user3 = Me.slct_auditor.Column(0, 2)
Me.user4 = Me.slct_auditor.Column(0, 3)
Me.user5 = Me.slct_auditor.Column(0, 4)
Me.user6 = Me.slct_auditor.Column(0, 5)
Me.user7 = Me.slct_auditor.Column(0, 6)
Me.user8 = Me.slct_auditor.Column(0, 7)

but when skipping the first item in the listbox it is still passed as into the textbox.

View 4 Replies View Related

Modules & VBA :: Deleting Values From A Table Selected From A List Box

Mar 19, 2014

Im trying to delete values from a table based on the selected values of a listbox. The listbox values have a hidden column which related to the ID on the table to which I am trying to delete from (if that makes sense).

If I use the following code:

Code:
Set ctl = Me.Results_listbox
For Each varItem In ctl.ItemSelected
CurrentDb.Execute "Delete * FROM Table1 WHERE Table1.ID = " & ctl.ItemData(varItem)
Next varItem

I get an error stating Object doesn't support this property or method.

View 7 Replies View Related

How To Store Selected Songs Ids In Db?

Feb 18, 2006

Hi all i have a db for my music collection. It has one table with the following feilds on it:

ID|filename|artist|album|title|track|comments|genr e|seconds|filesize|bitrate

I already created pages that with checkboxes that user select indvidual songs and by click of play button it goes and plays those songs for me.

Now i created another button next to play that it supposed to write the selected songs to db and save the ids of slected songs.Note: i use song ids to pull indvidual songs from db to be played by my song player!

My problem is i do not how to design a few tables that keep track of selected songs for each user along with the name of playlist for each user!! In processs i do not want to modify my current table i just want to add more tables to help me achive what i want. I be happy if an expert tell me how i can create tables that store play list(selected songs)info for each user and later i be able to query them easily in order to pull out playlist of each user.Thanks

View 3 Replies View Related

Modules & VBA :: ListBox Identify Selected Item Without Looping In Whole List

May 9, 2014

Show me the selected item in a Listbox without looping in the whole list, because my Listbox is multiselect and I want only the item that selected recently.

View 8 Replies View Related

Modules & VBA :: Enable Command Button When Item Selected From List Box

Oct 14, 2014

I have a simple listbox (single column, no multi-selection).I want to enable a command button when the user selects an item in the listbox / disable it if no items are selected.I'm using the AfterUpdate event of the listbox, as follows :

Code:

Private Sub lstOptions_AfterUpdate()
Select Case Me.lstOptions.ItemsSelected.Count
Case 0
Me.comConfirm.Enabled = False
Case Else
Me.comConfirm.Enabled = True
End Select
End Sub

But when I select an item from the listbox, and debug the code, the Count is always zero? Even though I can see the item selected??

View 2 Replies View Related

Modules & VBA :: Update Table Based On List Box Multi Selected Records

Nov 24, 2014

I have database with an userform called AssignWP, combobox called WPDevBy, listbox called List352 (Multi select) and table called Justified.I am trying to update one field WPDevelopedBy of the table as combobox value based on list box multi selected records.

View 2 Replies View Related

Option Group: How To Store Selected Button?

Aug 25, 2005

Hi,

On my form I have an option group with 4 radio buttons. Depending on the button selected certain fields become visible. This works all fine. Problem is though that I don't know how to store the selected value. At the moment, every time you open the form you have to select the same button to see the info stored in the fields that become visible. I guess that I'll have to somehow store the value for the selected buttons in the table. But How? Do I refer to the frame and store the value corresponding to the number of button (1, 2, 3 or 4) or do I store the balue for each button seperately?
I've played with it for too long now and cannot find the golden tip. Please advice.

Thanks,

Walt

View 5 Replies View Related

Select From List BOX Of List Of Choices And Store This Into A Table

Aug 21, 2013

I created a form and created on it a list box which is a query that grabs certain number of fields from different tables. I would like the user to select from this list box of a choice and then store their selection into a table.This list box has three fields, but it needs to store the id rather than the item, the user would see the name of the item but the id of the item would be store into another table, called bid. It store all these three fields when a user selection one of the item from the list.

View 13 Replies View Related

How To Determine Whether Or Not A Listbox Has Items Selected...?

Oct 6, 2006

Hello.

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 -_-

Thanks for any and all aide!

View 2 Replies View Related

Recall Selected Items From Listbox Selection

Oct 24, 2005

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:

ProjectNo - InvolvementType
123 - Testing
123 - Build
123 - Documentation
456 - Build
789 - Testing
789 - Documentation

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]));"

DoCmd.SetWarnings False
DoCmd.RunSQL strDelete
DoCmd.SetWarnings True

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

Regards
Robert

View 3 Replies View Related

A Tex Box Shoud Disable Once A Certain Dropdrop Items Is Selected

Nov 4, 2004

have a drop down menu on a form. When it has been updated to a certain value I want some of the field on my form to be disabled.

I am thinking it is a afterUpdate event, What would be the code to disable another field on the form

would it be something like this

If Forms![frmPlacements]![CostType] = "consultant" Then Forms![frmPlacements]![Wages].Disabled


CostType is a drop down menu with entry as follow: consultant, permananent, none and when consultant is selected the Wages text box should be disabled

Please look at the following post in a forum

[link]
http://www.access-programmers.co.uk...ead.php?t=75983 [/link]



Thanks

View 3 Replies View Related

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.

View 3 Replies View Related







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