473,405 Members | 2,141 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

need multi selection list box help

I set this up so the users can select more than one record so they can
update records a bunch at a time.
only one field is modified.
How can I edit this table easily instead of scrolling through the database
and comparing the selected items in the list box and comapring them to the
fields in the database.

Can you pass a list to an update query?

or can I edit one field in the database if I know the record number or that
ID number without having to loop through each one.

Thanks in advance

Nov 12 '05 #1
4 2654
Danny wrote:
I set this up so the users can select more than one record so they can
update records a bunch at a time.
only one field is modified.
How can I edit this table easily instead of scrolling through the database
and comparing the selected items in the list box and comapring them to the
fields in the database.
I don't know. From your problem definition above you don't mention what
you are comparing them too. Maybe you simply need an update query where
you compare the values between 2 tables and update where different.
Can't determine from your description.
Can you pass a list to an update query?
No. And Yes. Let's say you have a listbox called LB. It displays 5
columns. The Key field, ID, is displayed in the second column. You
want to filter for records you have selected in the listbox.

Dim var As Variant
Dim strHold As String
If Me.LB.Itemselected.Count > 0 then
For each var in Me.LB.Itemselected
'1 is the 2nd column since colcnt starts at 0
strHold = strHold & Me.LB.Column(1,var) & ", "
Next

'Remove the ", ".
'If ids selected are 1,2,3,4,5 the result is (1,2,3,4,5)
strHold = "(" & Left(strHold,len(StrHold)-2) & ")"

Me.Filter = "Id IN " & strHold
Me.FilterOn = True
Endif

I am passing a list, per se, with the value in strHold. See the help
topic "IN Operator"


or can I edit one field in the database if I know the record number or that
ID number without having to loop through each one.

Thanks in advance


Nov 12 '05 #2
Danny,

From my files. See below my SIG line ---
--
PC Datasheet
Your Resource For Help With Access, Excel And Word Applications
re******@pcdatasheet.com
www.pcdatasheet.com

Use Values From A Multiselect Listbox As Query Criteria

Loop through the ItemsSelected collection of the listbox and generate the SQL
string.
Dim SQLStr As String
Dim vSel As Variant
SQLStr = "SELECT <some fields> FROM <some tables> WHERE <criteria>"
With Me!ListBoxName
If .ItemsSelected.Count > 0 Then ' Did user select any rows?
SQLStr = SQLStr & " AND [ClassID] IN("
For Each vSel In .ItemsSelected
SQLStr = SQLStr & .Column(0, varItem) & ", "
Next vSel
SQLStr = Left(SQLStr, Len(SQLStr) - 2) & ");"
End If
End With

Note: The first (zeroth actually) column of the listbox is assumed to be a long
integer ClassID.


SQLStr can now be used as the RecordSource


"Danny" <da********@hotmail.com> wrote in message
news:TK**********************@news4.srv.hcvlny.cv. net...
I set this up so the users can select more than one record so they can
update records a bunch at a time.
only one field is modified.
How can I edit this table easily instead of scrolling through the database
and comparing the selected items in the list box and comapring them to the
fields in the database.

Can you pass a list to an update query?

or can I edit one field in the database if I know the record number or that
ID number without having to loop through each one.

Thanks in advance

Nov 12 '05 #3

"Danny" <da********@hotmail.com> wrote in message
news:TK**********************@news4.srv.hcvlny.cv. net...
I set this up so the users can select more than one record so they can
update records a bunch at a time.
only one field is modified.
How can I edit this table easily instead of scrolling through the database
and comparing the selected items in the list box and comapring them to the
fields in the database.

Can you pass a list to an update query?

or can I edit one field in the database if I know the record number or that ID number without having to loop through each one.

Thanks in advance


Thanks for your great responses and I will try them out.
BUT, this list can get large, like 1000 items in it, and I guess the sql
string will get huge. This is not good right?

Nov 12 '05 #4
Danny wrote:
"Danny" <da********@hotmail.com> wrote in message
news:TK**********************@news4.srv.hcvlny.cv. net...
I set this up so the users can select more than one record so they can
update records a bunch at a time.
only one field is modified.
How can I edit this table easily instead of scrolling through the database
and comparing the selected items in the list box and comapring them to the
fields in the database.

Can you pass a list to an update query?

or can I edit one field in the database if I know the record number or


that
ID number without having to loop through each one.

Thanks in advance

Thanks for your great responses and I will try them out.
BUT, this list can get large, like 1000 items in it, and I guess the sql
string will get huge. This is not good right?


Don't know. I had a similar question on this about a month ago. PC
Datasheet had a change on the recordsource. That would probably bomb as
the SQL string would be too large. It probably would not if it were
stored in a query.

I ran a test and stored a string of keys over 13000 bytes, as each key
was 5 bytes I had over 1000 keys. Then I set the filter and it worked
like a champ and was near instantaneous. So instead of changing the
recordsource you might want to change the filter instead. I figure as
long as your filter string is less than 64KB you should be OK.
Nov 12 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Neil Ginsberg | last post by:
I'm having a problem with a multi-select list box set to Simple multi-selection. If multiple items are selected and then I change the items in the list, the list positions previously selected are...
4
by: Danny | last post by:
I set this up so the users can select more than one record so they can update records a bunch at a time. only one field is modified. How can I edit this table easily instead of scrolling through...
6
by: Joe | last post by:
I have 2 multi-list boxes, 1 displays course categories based on a table called CATEGORIES. This table has 2 fields CATEGORY_ID, CATEGORY_NAME The other multi-list box displays courses based on...
2
by: google | last post by:
Hello everyone, I am having an issue using the "Multi Select" option in a list box in MS Access 2003. I am making a form that users can fill out to add an issue to the database. Each issue can...
2
by: bill yeager | last post by:
I need to get the SelectedValue of each item selected in a multi-selection listbox. I have the following code, but it just returns me the SelectedValue of ONLY the first item selected in the list:...
3
by: Julia | last post by:
I have a multi-value drop down box (<select name="Users" multiple>...) When my form is posted, i can read Request.Form.Item("Users"), a string that contains all values separated by comma. The...
10
by: SM | last post by:
Hello I'm trying to create a multi dimensional array in JavaScript, but after some reading i still can't figure out how to apply it to my model. Here it is: I have a list A and for each item...
1
by: freetime | last post by:
Greetings, This is my first post so I will try to be brief and accurate. I have a report that uses 9 user selectable filters (Dates, Y/N's as Combo Boxes and 4 Multi-Select List Boxes. ...
12
by: micarl | last post by:
How would i print a report based on criteria selected from several Combo Boxes as well as multiple Multi Select List Boxes, that are located on the same form? I can get one Multi List Box, just...
11
by: woodey2002 | last post by:
This problem is driving me crazy. Hello there, i am trying to create a search form for records in my access database. The search form will contain text boxes and a multi select list box. The user...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.