Forms :: Access 2003 - Scroll To Selected Item On Multiselect Listbox

Sep 2, 2013

I've got a form with a multiselect listbox (extended) that holds a very long list of items (~90,000):

1 | Apple
2 | Orange
3 | Banana
...............
35313| Corn cob
...............

The user can select multiple items (non-sequential) on the listbox, say items 1 and 35313. I'd like the listbox to scroll (meaning display) to the currrently selected item, so that the user can see it while being processed.

I've seen stuff about property ListIndex, which does exactly that, but it's only useful when you have just ONE item selected (in a multiselect listbox apparently it deselects the rest of the items, so no point in using it, I guess, unless there's more to it!!).

So the key here is how to do the scrolling/display.

The code to loop through the listbox and process each selected item is attached:

Code:
Dim vItem As Variant
Dim Content as String
For Each vItem In Me.lst.ItemsSelected
'scroll to selected item ???
'processing of the selected item
Content = Me.lst.Column(1, vItem) 'copy the content to do sth with it
Me.lst.Selected(vItem) = False 'unselect the current item
Next vItem 'go to next selected item

how to scroll to the currently selected item? Mind that I need to go through the list of selected items to process them for further use (i.e, I need them selected).

View Replies


ADVERTISEMENT

Forms :: How To Move Up And Down Selected Item In Access Form Listbox

Feb 10, 2014

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?

View 7 Replies View Related

Modules & VBA :: Scroll Listbox To The Top - No Selected Records

Apr 23, 2014

I'm using the following code to clear selected records from a listbox after a button is pressed:

Code:

For i = 0 To lstProducts.ListCount - 1
lstProducts.Selected(i) = False
Next

The code works great except that it leaves the listbox scrolled all the way to the bottom. What is the best way to scroll back up to the top of the listbox without selecting another record?

View 3 Replies View Related

Save Columns Of Listbox Selected Item

Jul 23, 2007

Hi all,

Does anyone know how to get the columns of a listbox selected item and store it to a string? There is no multi-selection so it should be easier. I tried
s$ = Me.list1.selected but it keeps giving me an error

Thanks alot

View 3 Replies View Related

Modules & VBA :: Determine If Item From Listbox Is Selected

Jun 12, 2014

I am having trouble with a If statement. I am trying to save a record into a table when an item is Selected (highlighted blue) in a list box. Keep in mind that my listbox is set to multiple selections. I have the following code but sometimes it works and sometimes it doest.

The reason why I am trying to get this to work is because when a item is selected I will add it to the table and when an item is deselected I will delete it from a table. See my code and pictures I have attached :

Private Sub list_audits_Click()
Dim strsql As String
Dim list As String
Dim id As String
id = Me.User_ID.Value

[Code] ....

View 2 Replies View Related

Queries :: Get Information From Selected Item Of ListBox

Nov 22, 2013

From a search form example I got from this forum I made the following:

A listBox which shows results as you type, using a query.

This listBox has 1 column, I need it that way.

What I need is to show the information from the selected item of the listBox on a textBox, getting this info from the results of the query.

I found 2 answers which I don't like:

1- =DLookUp("[Column]","[Query]") as source of textBox

This shows only information from the first row. So if you select the second result from the listBox, it still shows the first row.

2- =SearchResults.column(int) as source of textbox

It does not work, because listBox has only 1 column.

View 4 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

Forms :: How To Move Item In Listbox Up And Down Access VBA

May 21, 2014

I have a list box contains 10 times . I have UP and Down buttons to move item up and down. My VBA works only if i set listbox multiselect property to 'None'. For the multiselect=simple option it throws error like in valid use of null in this line of code :

sText = lbfNames.Column(0, iIndex)

My VBA

Code:

Private Sub cmdUP_Click()
Dim sText As String
Dim iIndex As Integer
iIndex = lbfNames.ListIndex
'check: only proceed if there is a selected item

[Code] ....

View 8 Replies View Related

Forms :: Multi Select Listbox Access 2003 Code Gives Syntax Error In MS Access 2010

Oct 24, 2013

I've been using the following code successfully in Access 2003 & now I need to migrate to Access 2010. The purpose of the code is to use the items that the user selects in the list box to build the criteria of a query. Access 2010 keeps giving me a syntax error when I try to run the query & I don't know why:

My code is:

On Error GoTo Err_Command151_Click

' Declare variables
Dim db As DAO.Database
Dim qdf As DAO.QueryDef
Dim varItem As Variant
Dim strCriteria As String
Dim strSQL As String

[Code] .....

The syntax error I get in Access 2010 is:

Syntax Error in query expression 'SELECT * FROM
qryContractListSummarybyDateContract3TYPEBREAK WHERE
qryContractListSummarybyDateContract3TYPEBREAK.Rep ortableName IN('Adbri
Masonry NSW');'

View 12 Replies View Related

Forms :: Listbox Multiselect - Adding Records To Junction Table

Apr 21, 2014

I would like to use a listbox set to multiselect to add records to a junction table. I've been using code to accomplish this with checkboxes (love how it looks and works) but after moving my tables to Office 365 as the backend, linkedto a local frontend, sql does not like this particular set up, and I do not have the time or knowledge to sort out why. So what I need is a step by step to look at the many, in this case possible roles a contact can have, and choose one or more, which then creates a record in the junction table with the contact id and role id.

I would prefer to not use a combobox on a continuous form because every time a user goes to select roles he would have to scroll through all the choices for each separate role.

View 5 Replies View Related

General :: Access Form - Scroll Box Does Not Bring The Selected Value Up

Sep 18, 2013

I have added a scroll list to my access form and although I can see the item I need to pick in the drop down list when I manually start typing it, the scroll box doesn't bring the value up and states that the value I have selected is not in the list (when it clearly is !!)

View 10 Replies View Related

Is It Possible To Select The Same Item Twice Using A MultiSelect List Box

Jun 29, 2007

I would like to be able to create a recipe (saved in its own table) by pulling items from a multiselect list box (from the raw materials table) but which allows me to add the same ingredient more than once.

I work for a chemical manufacturing company and we need to track the cost of goods by recipe (final product), by linking the ingredients (where the cost of the raws are associated) to the final prodcut. Several of our products need to have chemicals added in the beginning, but then again at the end of the procedure unlike normal kitchen recipes.

(I sure hope I don't have to learn VBA . . . I'm totally new at Access!)

Thanks in advance for your help.

View 3 Replies View Related

Modules & VBA :: Access 2007 - Scroll Listbox Back To Top Without Changing Selections

Jan 29, 2014

I have a listbox which is populated by a query from a table.

I also have a sub which allows users to quickly select multiple items from the listbox (based on a pre-defined criteria) rather than scrolling through and selecting them manually / individually

The sub works fine but when it is finished, the listbox is automatically scrolled to the bottom (or, rather, to the last selected item)

I would like to have the listbox scroll back to the very top once all of the appropriate items have been selected.

(I could loop through the listbox items in reverse - or 'bottom-up' - in the code but that would only have the desired effect if the topmost item was selected. I want it scrolled to the top regardless of whether the topmost item is selected or not).

View 2 Replies View Related

Forms :: Remove Item After Being Selected From Combobox?

Mar 30, 2015

How can I remove an item after being selected from a combobox ?

View 2 Replies View Related

Forms :: Fill Value In Textbox When Item From Combobox Is Selected

May 19, 2013

I have a table, Registration, with 8 fields:

inschrijvingsid,name,gemeente,gsm,telefoon,email,a ankomst,gerecht,personen

I have another table, Login with 3 fields : Naamid,name,,status

Then I have a combox that is connected with fldname from the table Login.

In that form I have 8 textboxes:

name,
gemeente,
gsm,
telefoon,
email,
aankomst,
gerecht,
personen

And status.

Now what I can't. I want when I select a record from tblLogin Like for example Daan that I see in the textboxes his info from the tableRegistration.

Also when I change the textbox Status it and click "Verander status" it changes in the database.

View 3 Replies View Related

Forms :: Combo Box With Msgbox If Selected Item Is Not In Record

Oct 30, 2014

I want a Messagebox to be appear if the selected item or if the input item in the combobox was not in the record.

I used this condition in combobox

="[asstnumbr] = " & "'" & [Screen].[ActiveControl] & "'"

but when I try this run code function in macro via IFF will become error

IIf([asstnumbr]<>"'" & [Screen].[ActiveControl] & "'",MsgBox("NO RECORD FOUND IN YOUR SEARCH"))

View 1 Replies View Related

Forms :: Make Listbox Autoselect If Only 1 Item

Sep 26, 2013

My form utilizes five list boxes. The user must choose from each of the five list boxes in order to filter out a specific product from a products table.Every time the user makes a selection, the next listbox is filtered, and set focus to. Each listbox often contains more than 1 choice within it, however, there are a few cases where there is only 1 choice to be made.

How can i determine with code when a particular listbox only has 1 choice so that I can have the choice be made automatically and then set the focus to the next listbox in the series?

View 2 Replies View Related

MultiSelect Listbox

Apr 19, 2005

I have a table, "people" which has all the main data stored. I have another table, "organizations" which I'd like to be able to use on a form to select which organizations people belong to. I created a button on my main form which opens another form on which a listbox with all the organizations shows. What I'd like to do is from the main form, click a button that brings up a new form. On the new form, I can select the affiliations. Then, when I close that form, a box on the main form shows what i've just selected. I got this to work with the listbox, but when I changed it to multi-select it stopped working. Help!! Thanks.

View 5 Replies View Related

MultiSelect ListBox

Jun 25, 2005

I want to be able to select multiple items from a listbox, click a button, and then print the data related to that item selected using a report.

In the report to print the data, I have added the criteria
[Forms]![Print Labels]![List2]
This is the name of the listbox. However, this doesn't print the items selected in the list box.

Do I have to do this through VBA, or can I accomplish this through a query in the report?

Thanks!

View 1 Replies View Related

Forms :: How To Remove Item From Listbox When Checkbox Is Unclicked

Apr 22, 2013

I'm using Access 2010 and have a form that is basically the last step in generating a report (which will be a printable invoice).

I am facing major problems when it comes to removing line items that the user may have accidentally clicked. I have a checkbox field embedded in the table (tblLineItems) which is set up as binary. I have created a form from tblLineItems, and have in turn embedded that as a subform on the invoice generating form.

When I select line items, I have them populating a two column listbox that shows the user what they have selected before actually opening the report. The code I am using is on the checkbox click event in the subform:

Code:
Private Sub InvoiceY_N Click()
Dim InvLineTotal As Currency
If InvoiceY_N.Value = True Then

[Code].....

View 13 Replies View Related

Forms :: Deselect Or Remove Highlight From Item In Listbox

Jul 2, 2014

I am using Access 2010.

I have a form with three listbox. My issue is this, when I go from listbox to listbox the selected item in the previous listbox is still selected.

I would like it so when I go to the new listbox, then the previous listbox selection will no longer be highlighted.

I use the follow code, which works but the user has to double click on the listbox with the focus to make a selection.

Code:

Me.listbox.listindex = -1

I have the code in the lost focus event of the listboxes.

Is there a way to prevent the double clicking?

View 7 Replies View Related

Multiselect Values In A Listbox

Jan 28, 2005

I was wondering whether it is possible to select multiple values in a list box on a form that can be stored in a table.

View 4 Replies View Related

Clear MultiSelect Listbox

May 21, 2007

I have a multiSelect Listbox that has email recipients. I have a command button with Me.emaillist = Null, and after I click the command button the Listbox is still highlighted in black. What VBA command do I create to completely clear the multiSelect Listbox, including the highlighted selection?

losstww

View 1 Replies View Related

Multiselect Listbox Passing To A Field

Jan 26, 2005

I'm trying to create a database where a single "Classification" field is populated by selections made in a multiselect listbox and I can't figure out how to do this. Any help people can provide?

Table 1:
Name_ID <pk>
Name
Classification

Table 2:
Classification_ID <pk>
Classification

What I want to happen is click on a button next to the Classification field (text) and a popup form with a multi-select list loads (this part is easy, of course). The user can select as many classifications as they want, click the ok button and each item selected then goes back to the first form and populate in the Classification field (seperated by commas or semi-colons).
This possible?

View 3 Replies View Related

Problem With Code In Multiselect Listbox

Jan 27, 2005

Hi,

I have adapted code from ghudson's example on
'http://www.access-programmers.co.uk/forums/showthread.php?s=&threadid=52736

I have a subform called frmsJobPartsUsed, which contains a multiselect list box where the user can select multiply parts used for one job and click a save button, which saves the parts to rows on the same forms (see picture). The user then enters the number used and that number is taken away from the UnitsInStock.
This form is made up of the following two tables;
TblStore
PartNo
PartName
UnitsInStock
ReOrderLevel
Discountinued
Remark

tblPartsUsed
PartUsedID
JobDetailsID
PartNo
PartUsedNum
NumberUsed

The multiselect listbox is made form tblStore, PartNo, PartName and Discontinued = 0

This all works fine so far.

What is need to do is before the parts selected are saved to the table I want to run some code to check
If a part’s UnitsInStock is equal to 0 then Message box saying no stock left need to reorder. It won’t save it to the table.
Or else
If UnitsInStock is greater than 0 but less than or equal to ReOrderLevel
Message box saying Stock running low need to reorder asap.

I have this kind of working but it doesn’t seem to be finding the correct UnitsInStock for the part selected.
Here is the code;


Private Sub cmdAnswer_Click() 'SAVE BUTTON
On Error GoTo ErrMsg:

'Code adapted from ghudson's example on
'http://www.access-programmers.co.uk/forums/showthread.php?s=&threadid=52736

Dim myFrm As Form, myCtl As Control
Dim mySelection As Variant
Dim iSelected, iCount As Long

Dim myDB As DAO.Database
Dim myRst As DAO.Recordset
Dim myRstCount As DAO.Recordset

Set myDB = CurrentDb()
Set myRst = myDB.OpenRecordset("tblPartsUsed")

Set myFrm = Me
Set myCtl = Me.lstAnswers

iCount = 0
'Count number of selected records/items
For Each mySelection In myCtl.ItemsSelected
iCount = iCount + 1
Next mySelection

'Check if anything is slected
If iCount = 0 Then
MsgBox "There are no Parts selected..", _
vbInformation, "Nothing selected!"

Exit Sub
End If

StrSQLCount = "SELECT tblPartsUsed.JobDetailsID, Count(tblPartsUsed.PartNo) AS CountOfPartNo " & _
"FROM tblPartsUsed " & _
"GROUP BY tblPartsUsed.JobDetailsID " & _
"HAVING (((tblPartsUsed.JobDetailsID)=" & [Forms]![frmJobs]![JobDetailsID] & "));"
Set myRstCount = myDB.OpenRecordset(StrSQLCount, dbOpenSnapshot)




'SART OF MY CODE TO CHECK FOR UNITSINSTOCK

For Each mySelection In myCtl.ItemsSelected
If Me.UnitsInStock.Value = 0 Then
MsgBox "Out of Stock!" & Chr(13) & "Please returen to Orders or Store to Re-Order Stock. " & Chr(13) & " ", vbOKOnly + vbCritical, "Re-Order Stock"
myCtl.Selected(mySelection) = False

Else
If Me.UnitsInStock.Value > 0 And Me.UnitsInStock <= Me.ReOrderLevel.Value Then
MsgBox "The Store is running low on stock!!" & Chr(13) & " Please return to Orders or Store to re-order as soon as possible.", vbInformation, "Need to Re-Order Stock"
End If
End If
Next mySelection
'END





iCount = 0

'Go throught each selected 'record' (ItemsSelected) in listbox
For Each mySelection In myCtl.ItemsSelected
'Current count of selected items
iCount = iCount + 1
'Print value to Immediate Window
Debug.Print myCtl.ItemData(mySelection)
'Add answers
With myRst
.AddNew
.Fields("JobDetailsID") = Forms![frmJobs]![JobDetailsID]
.Fields("PartUsedNum") = iCount
.Fields("PartNo") = myCtl.ItemData(mySelection)
.Update
End With
Next mySelection

'Requery form
Me.Requery

ResumeHere:
Exit Sub

ErrMsg:
MsgBox "Error Number: " & Err.Number & _
"Error Description: " & Err.Description & _
"Error Source: " & Err.Source, vbCritical, "Error!"
Resume ResumeHere:

End Sub



Private Sub cmdUnselect_Click() 'UNSELECT BUTTON
On Error GoTo ErrMsg:

'Code adapted from ghudson's example on
'http://www.access-programmers.co.uk/forums/showthread.php?s=&threadid=52736

Dim myFrm As Form, myCtl As Control
Dim mySelection As Variant
Dim iSelected, iCount As Long

Set myFrm = Me
Set myCtl = Me.lstAnswers

'Count number of selected records/items
For Each mySelection In myCtl.ItemsSelected
iCount = iCount + 1
Next mySelection

If iCount = 0 Then
MsgBox "There are no selections to Un-Select..", _
vbInformation, "Nothing selected!"
End If

'Go throught each selected 'record' (ItemsSelected) in listbox
For Each mySelection In myCtl.ItemsSelected
Debug.Print myCtl.ItemData(mySelection)
myCtl.Selected(mySelection) = False
Next mySelection

ResumeHere:
Exit Sub

ErrMsg:
MsgBox "Error Number: " & Err.Number & _
"Error Description: " & Err.Description & _
"Error Source: " & Err.Source, vbCritical, "Error!"
Resume ResumeHere:
End Sub







Any help would be greatly appreciated.
Thanks in advance
Rita

View 1 Replies View Related

Multiselect Listbox Passing To A Field

Apr 19, 2005

OK - I have seen the other posts where individuals are trying to select multiple items from a list box and have a field populate with the selections. I have not seen a clear explanation defining if this is possible.

Essentially, I want to be able to query on the field and search for multiple selections within that field. Any recommendations as to how this can be achieved?

My next question, is if the selections in a multiple instance field are separated by a comma or some other character what is the best method to query for multile responses. For example, if the following data is in the field 1,2,3 and I want to query on 1 or 2?

Regards,
PolarBear

View 3 Replies View Related







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