Hello,
I'm sure this is such a simple question I didn't even want to bother posting but for the life of me I just can't get it to work : (
I have a button that toggles "Select All" and "Select None". Whenever the user clicks "None" it runs a function that clears a series of data and likewise when they click "All" it inputs a long series of data. The function works as long as the user actually CLICKS each item, however with a listbox of 100+ entries the users will not be clicking each unit individually lol
The "Select All" code that I'm using is very standard: - For intcounter = 0 To SelectionLst.ListCount
-
InputGoodies
-
SelectionLst.Selected(intcounter) = True
-
Next intcounter
The function "InputGoodies" needs to run the way it would if I ran it OnClick for the listbox. My on-click is just as simple: - If SelectionLst.Selected(SelectionLst.ListIndex) = "-1" Then
-
InputGoodies
-
Else
-
...
Is there any way to make some kind of loop that will do the above function for each item in the ListCount? I don't understand why I can't get it to work, I feel like I've tried everything. Help is completely appreciated!! : D
-Cathy
15 17574
Hello,
I'm sure this is such a simple question I didn't even want to bother posting but for the life of me I just can't get it to work : (
I have a button that toggles "Select All" and "Select None". Whenever the user clicks "None" it runs a function that clears a series of data and likewise when they click "All" it inputs a long series of data. The function works as long as the user actually CLICKS each item, however with a listbox of 100+ entries the users will not be clicking each unit individually lol
The "Select All" code that I'm using is very standard:
For intcounter = 0 To SelectionLst.ListCount
InputGoodies
SelectionLst.Selected(intcounter) = True
Next intcounter
The function "InputGoodies" needs to run the way it would if I ran it OnClick for the listbox. My on-click is just as simple:
If SelectionLst.Selected(SelectionLst.ListIndex) = "-1" Then
InputGoodies
Else
...
Is there any way to make some kind of loop that will do the above function for each item in the ListCount? I don't understand why I can't get it to work, I feel like I've tried everything. Help is completely appreciated!! : D
-Cathy
Cathy, I'm a little hazy on exactly what you are requesting. Assuming your List Box name is List1, the following code will pass each value in the List Box (List1) to the SomeValue() Function, where it will be adjusted or operated on in some manner. ALL entries in the List Box will be passed to the Function regardless of whether they are selected or not. Is this what you are looking for? - Dim intItemsInList As Integer, intCounter As Integer
-
Dim lst As ListBox
-
-
Set lst = Me![List1]
-
-
intItemsInList = lst.ListCount
-
-
For intCounter = 0 To intItemsInList - 1
-
SomeFunction (lst.ItemData(intCounter))
-
Next
NeoPa 32,556
Expert Mod 16PB
...
The "Select All" code that I'm using is very standard: - For intcounter = 0 To SelectionLst.ListCount
-
InputGoodies
-
SelectionLst.Selected(intcounter) = True
-
Next intcounter
...
Your code looks good to me Cathy.
The only thing that occurrs to me is that maybe the function InputGoodies() only processes the item if it's already selected. In that case move line 2 after line 3 for better results.
Well I tried both of the suggestions but I still can't get this to work : (
The "InputGoodies" function that I'm referencing looks like this: -
Public Sub InputGoodies()
-
-
If Price1.Value = "0" Then
-
Price1.Value = SelectionLst.Column(5)
-
SqFt1.Value = SelectionLst.Column(4)
-
...
-
..and it goes on for another hundred lines asking questions, running loops, and such. The situation is that when I use a Select All function it DOES run "InputGoodies" X times but it only uses the FIRST SELECTED listbox item as the value (the item that the user may or may not click on). So if they load up the listbox and just click "Select All", it may run "InputGoodies" 30-some times but it wont reference any values from the listbox. IF the user happens to click one of the list items and then clicks Select All, it will run InputGoodies 30-some times and will use that ONE selected value for everything.
So the problem is that my function requires the item to be selected for it to work. If there was some way to simulate a listbox item being selected for each instance in the loop then it should work so it should go something like:
1. Count how many items are in the listbox
2. Select the first item
3. Run my function
4. Repeat X times
I'm so sure this is really easy and I can't believe I haven't figured it out by now but the past weekend I was moving and I didn't get any work done.
NeoPa 32,556
Expert Mod 16PB
In that case it is indeed important to call the function after the selection is set. - For intCounter = 0 To SelectionLst.ListCount
-
SelectionLst.Selected(intCounter) = True 'line needs to be changed
-
Call InputGoodies()
-
Next intcounter
Setting the selection must be done differently as you are not checking the selected items in your InputGoodies() code but only the "active" item.
In the same way that Excel has a Selected list but also has an Active item, so too does an Access ListBox (You must have the MultiSelect property of the ListBox set to Simple or Extended).
Let me see if I can dig up the way to set the Active item rather than simply adding it to the list (as this is what your code uses - it ignores selected items).
NeoPa 32,556
Expert Mod 16PB
Why don't you try : - For intCounter = 0 To SelectionLst.ListCount
-
Call SelectionLst.SetFocus()
-
SelectionLst.ListIndex = intCounter
-
Call InputGoodies()
-
Next intcounter
Why don't you try : - For intCounter = 0 To SelectionLst.ListCount
-
Call SelectionLst.SetFocus()
-
SelectionLst.ListIndex = intCounter
-
Call InputGoodies()
-
Next intcounter
I think this is the right direction (using the setfocus maybe) but when I run this it tells me "Runtime Error: 7777 You've used the ListIndex Property Incorrectly".
The debug process highlights "SelectionLst.ListIndex = intCounter" as the problem. The ListIndex count was at 19 and the intCounter was at 20 if that will help. I'm really curious now about this. NeoPa you've been a big help so far - you have any suggestions?? : )
It could very well be something I'm doing wrong but everything I'm explaining seems pretty simple on the plane of access development.
Hmmmmm...
NeoPa 32,556
Expert Mod 16PB
Cathy,
I just dug this up from the help file really. I don't have a lot of experience with it.
If it's easy, could you attach a copy of your database to a new post and let me know which version of Access you're using. I can't imagine that the last would make much of a difference, but it won't hurt to know.
If this fails of course, then it might be necessary to recode your other function (InputGoodies()).
If you can't (or don't want to) attach your database then we'll just have to see what we can find out by rebuilding something similar.
Cathy,
I just dug this up from the help file really. I don't have a lot of experience with it.
If it's easy, could you attach a copy of your database to a new post and let me know which version of Access you're using. I can't imagine that the last would make much of a difference, but it won't hurt to know.
If this fails of course, then it might be necessary to recode your other function (InputGoodies()).
If you can't (or don't want to) attach your database then we'll just have to see what we can find out by rebuilding something similar.
Hi NeoPa,
Well I couldn't upload my database because even the front-end is almost 20Mb right now but I was able to at least re-create my problem (I added some comments so you get an idea). It's a very simple re-enactment of what I'm trying to do. I'm hoping that by doing this, it will make this problem resolve itself via becoming self-evident lol
Thanks for taking the time to help me out : ) http://www.rjpinc.net/uploads/sample.zip NeoPa 32,556
Expert Mod 16PB
I'll have a look at it but I'm out all tomorrow night.
Give this a bump on Thursday if you've not heard from me.
NeoPa 32,556
Expert Mod 16PB
I'm sorry Cathy, I've downloaded the db but I haven't had a chance yet to look at it. I'll check it tomorrow or the weekend. Unfortunately I can't do that sort of stuff at work - must be from home (evenings & weekends).
NeoPa 32,556
Expert Mod 16PB
I'm at work at the moment so have no access to the uploaded database, but I've given it some thought and it seems to me that what is called for in this case is surely that the InputGoodies() function is recoded to work with all selected items rather than simply to work with the currently active item.
Not only would this get around your problem, it would also (to my mind) be the most appropriate way to handle it.
When I look at things later I'll look at them with this idea in mind.
NeoPa 32,556
Expert Mod 16PB
Cathy,
Still haven't got to this I'm afraid.
I've had a lot of "homework" questions recently and allowed this one to slip down the list (again) so I'm sorry for that and will remember to look at it tonight (barring only extreme and unforeseen circumstance).
Please feel free to bump any time as this one is long overdue for a serious look at.
Cathy,
Still haven't got to this I'm afraid.
I've had a lot of "homework" questions recently and allowed this one to slip down the list (again) so I'm sorry for that and will remember to look at it tonight (barring only extreme and unforeseen circumstance).
Please feel free to bump any time as this one is long overdue for a serious look at.
I appreciate your help NeoPa : ) I personally have been doing a lot of other access related coding and I've just neglected this item for now. Anyone else who wants to look at this as well is more than welcome to share their input : D
NeoPa 32,556
Expert Mod 16PB
Right Cathy, I couldn't work out why you were doing quite what you were doing but I coded up the InputGoodies() function to process through the list itself in the closest guess I could manage of what your logic was intended to be :S
As I said earlier, you need something to process through the ItemsSelected collection. There's little point in the Command2 code doing it if there's no parameter to the InputGoodies() function to pass it through in.
Anyway, see if this makes sense. - Public Sub InputGoodies()
-
Dim intX As Integer
-
-
With Me.List0
-
intX = 0
-
If .ItemsSelected.Count > intX And X = "" Then
-
X = .Column(1, .ItemsSelected(intX))
-
intX = intX + 1
-
End If
-
If .ItemsSelected.Count > intX And Y = "" Then
-
Y = .Column(1, .ItemsSelected(intX))
-
intX = intX + 1
-
End If
-
If .ItemsSelected.Count > intX And Z = "" Then
-
Z = .Column(1, .ItemsSelected(intX))
-
intX = intX + 1
-
End If
-
End With
-
End Sub
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Mike |
last post by:
I have a mulitpage form that I do not record the information into a dbase
until the end.
I need to pass the field values form on form to the next. I have the code
for automatically
generating...
|
by: ajay.sonawane |
last post by:
Want to ask one thing about RSS ( Really Simple Syndication )
I went through RSS specifications. Read all fields of item and channel.
But didn't find any field that could help me to store some of...
|
by: hiroshi ochi |
last post by:
Hello,
Using MSIE 6.0 and above, with javascript is it possible to display an
individual tooltip for each item in a listbox?
I need this functionality to show the listitems that are longer...
|
by: Tony |
last post by:
TIA
|
by: vikram |
last post by:
How can i add a user define attribute to each checkbox
item in a checkbox list control.
I want to add a attribute "Tag".
Is it possible
|
by: Drew |
last post by:
I need to iterate through a submitted form, inserting data on each pass. In
the past, I have always used form elements that were named with numbers at
the end, like this,
name1 relationship1...
|
by: Krishna |
last post by:
Hi All,
Scenerio: There are many contracts. Each contract has some items for
which the contract has been established. So i have to display the
Rebate on each item of each contracts. There is...
|
by: Priya |
last post by:
I have to display a checboxlist with someitems when each item in a listbox is
selected. I have a listbox with a list of categories and when i click each
category from the listbox, the checkbox list...
|
by: liz0001 |
last post by:
I am trying to run an SQL query for each item in an Array using ASP.
I have coded it as such. IDsArray() is an array of integers.
ArrayLength=15
sqlGetiIDs = "SELECT * FROM Table1 WHERE...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
by: PapaRatzi |
last post by:
Hello,
I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
by: Shællîpôpï 09 |
last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
|
by: af34tf |
last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome former...
| |