Looks as though your example didn’t get attached. Be sure to attache the file as the last step. And you will probably need to zip the file before attaching it.
![]() |
Patch reliability is unclear. Unless you have an immediate, pressing need to install a specific patch, don't do it. |
SIGN IN | Not a member? | REGISTER | PLUS MEMBERSHIP |
-
Multipick (Access 2000)
Home » Forums » AskWoody support » Productivity software by function » MS Access and database help » Multipick (Access 2000)
- This topic has 19 replies, 6 voices, and was last updated 19 years, 4 months ago.
Viewing 0 reply threadsAuthorReplies-
WSkeks
AskWoody LoungerJanuary 4, 2006 at 9:23 am #992670I would like to extent my question:
i have copied a wonderful example from Access 200 developers handbook and i need help to modify it to my needs.I am attaching the example.In this example i get the list of the products according to
the grade.I want however to show also the size and the pack, as obtained in the query qryProducts. I have tried the following but i got red letters:
mmp.SetData “qryProducts”, “Grade”,”size”,”pack”I want to open a report based on the selection in the list box of a form.Can i do it ? According to my attachement, the form is called frmMultick and the listbox is called LstSelected.
In the OnClick event i have written the folloiwng :
Dim aSelected() As Variant
Dim varItem As Variant‘ Get an array filled with the selected items.
aSelected = mmp.SelectedItems
For Each varItem In aSelected
strShowIt = strShowIt & varItem & vbCrLf
Next varItem
DoCmd.OpenReport “Rpt1” -
WSNYIntensity
AskWoody Lounger -
WSkeks
AskWoody Lounger -
WSpatt
AskWoody Lounger -
WSkeks
AskWoody Lounger -
WSpatt
AskWoody Lounger -
WSHansV
AskWoody LoungerJanuary 4, 2006 at 9:18 am #992777I wouldn’t use the After Update event of the list box, and I wouldn’t create a query. It can be done in a much more simple way in the On Click event of the command button:
Private Sub Command2_Click()
Dim varItem As Variant
Dim strWhere As String
For Each varItem In Me.lstProducts.ItemsSelected
strWhere = strWhere & “, ‘” & Me.lstProducts.ItemData(varItem) & “‘”
Next
If Not strWhere = “” Then
strWhere = Mid(strWhere, 3)
strWhere = “grade in (” & strWhere & “)”
End If
DoCmd.OpenReport “RPT1”, acViewPreview, , strWhere
End SubSee attached version.
-
WSkeks
AskWoody Lounger -
WSkeks
AskWoody Lounger -
WSNYIntensity
AskWoody Lounger -
WSkeks
AskWoody LoungerJanuary 4, 2006 at 6:05 pm #992890Dear Hans,
The code works great! . i came accross the following details..If i have products with one and the same name but with different sizes and packs, then even i choose one product, i get all the products in the report.For example, if the first three products are called pears,but with different sizes,then on choosing only one products all the three products appear on the report.How can i avoid that ?
-
WSHansV
AskWoody LoungerJanuary 4, 2006 at 8:16 pm #992913You can set the Bound Column property to 1 instead of 2, and change the code behind the command button as follows:
Private Sub Command2_Click()
Dim varItem As Variant
Dim strWhere As String
For Each varItem In Me.lstProducts.ItemsSelected
‘ Note the absence of quotes, since ProductID is a number field
strWhere = strWhere & “, ” & Me.lstProducts.ItemData(varItem)
Next
If Not strWhere = “” Then
strWhere = Mid(strWhere, 3)
strWhere = “ProductID In (” & strWhere & “)”
End If
DoCmd.OpenReport “RPT1”, acViewPreview, , strWhere
End SubSee attached version
-
WSramonas
AskWoody Lounger -
WSHansV
AskWoody LoungerJanuary 6, 2006 at 7:48 pm #993311You shouldn’t use the After Update event of the list box, because it fires each time the user selects or deselects an item. Instead, you should put a command button on the form and put the code in the On Click event of the button.
Your query is based on tblCurrent only, but you try to set a condition on the Job field from tblJoblist. I think you want a condition on the Activity field instead.
If an error occurs, the query qryRTM1 may already have been deleted. Next time, the instruction db.QueryDefs.Delete “qryRTM1” will cause the error message you mention.
You don’t really need to delete the query, you only need to change its SQL statement. Or put a line On Error Resume Next before the delete statement.You should build in a check for the situation where the user hasn’t selected any items.
Here is revised code:
Private Sub cmdProcess_Click()
Dim varItem As Variant
Dim strTemp As String
Dim strSQL As String
Dim db As DAO.Database
Dim qry As DAO.QueryDefOn Error GoTo ErrHandler
If Me.lstProducts.ItemsSelected.Count = 0 Then
MsgBox “Please select one or more products!”, vbInformation
Exit Sub
End If
strSQL = “SELECT Activity, Cost_Code, Date, Timesheet_Date, Hours FROM tblCurrent ”
For Each varItem In Me.lstProducts.ItemsSelected
strTemp = strTemp & “Activity = ‘” & Me.lstProducts.ItemData(varItem) & “‘ Or ”
Next varItemstrSQL = strSQL & “WHERE ” & Left(strTemp, Len(strTemp) – 4)
Set db = CurrentDbOn Error Resume Next
db.QueryDefs.Delete “qryRTM1”
On Error GoTo ErrHandler
Set qry = db.CreateQueryDef(“qryRTM1”, strSQL)
Exit SubErrHandler:
MsgBox Err.Description, vbExclamation
End Sub -
WSramonas
AskWoody Lounger -
WSNYIntensity
AskWoody LoungerJanuary 7, 2006 at 4:49 pm #993419 -
WSHansV
AskWoody Lounger -
WSNYIntensity
AskWoody Lounger -
WSHansV
AskWoody Lounger
-
-
-
-
Viewing 0 reply threads -

Plus Membership
Donations from Plus members keep this site going. You can identify the people who support AskWoody by the Plus badge on their avatars.
AskWoody Plus members not only get access to all of the contents of this site -- including Susan Bradley's frequently updated Patch Watch listing -- they also receive weekly AskWoody Plus Newsletters (formerly Windows Secrets Newsletter) and AskWoody Plus Alerts, emails when there are important breaking developments.
Get Plus!
Welcome to our unique respite from the madness.
It's easy to post questions about Windows 11, Windows 10, Win8.1, Win7, Surface, Office, or browse through our Forums. Post anonymously or register for greater privileges. Keep it civil, please: Decorous Lounge rules strictly enforced. Questions? Contact Customer Support.
Search Newsletters
Search Forums
View the Forum
Search for Topics
Recent Topics
-
*Some settings are managed by your organization
by
rlowe44
7 hours, 4 minutes ago -
Formatting of “Forward”ed e-mails
by
Scott Mills
9 hours, 18 minutes ago -
SmartSwitch PC Updates will only be supported through the MS Store Going Forward
by
PL1
9 hours, 42 minutes ago -
CISA warns of hackers targeting critical oil infrastructure
by
Nibbled To Death By Ducks
18 hours, 43 minutes ago -
AI slop
by
Susan Bradley
17 hours, 54 minutes ago -
Chrome : Using AI with Enhanced Protection mode
by
Alex5723
20 hours ago -
Two blank icons
by
CR2
5 hours, 33 minutes ago -
Documents, Pictures, Desktop on OneDrive in Windows 11
by
ThePhoenix
1 day, 4 hours ago -
End of 10
by
Alex5723
1 day, 7 hours ago -
Single account cannot access printer’s automatic duplex functionality
by
Bruce
5 hours, 28 minutes ago -
test post
by
gtd12345
1 day, 13 hours ago -
Privacy and the Real ID
by
Susan Bradley
1 day, 3 hours ago -
MS-DEFCON 2: Deferring that upgrade
by
Susan Bradley
19 hours, 49 minutes ago -
Cant log on to oldergeeks.Com
by
WSJonharnew
1 day, 17 hours ago -
Upgrading from Win 10
by
WSjcgc50
5 hours, 38 minutes ago -
USB webcam / microphone missing after KB5050009 update
by
WSlloydkuhnle
9 hours, 12 minutes ago -
TeleMessage, a modified Signal clone used by US government has been hacked
by
Alex5723
2 days, 9 hours ago -
The story of Windows Longhorn
by
Cybertooth
1 day, 21 hours ago -
Red x next to folder on OneDrive iPadOS
by
dmt_3904
2 days, 11 hours ago -
Are manuals extinct?
by
Susan Bradley
5 hours, 15 minutes ago -
Canonical ditching Sudo for Rust Sudo -rs starting with Ubuntu
by
Alex5723
2 days, 20 hours ago -
Network Issue
by
Casey H
2 days, 7 hours ago -
Fedora Linux is now an official WSL distro
by
Alex5723
3 days, 8 hours ago -
May 2025 Office non-Security updates
by
PKCano
3 days, 9 hours ago -
Windows 10 filehistory including onedrive folder
by
Steve Bondy
3 days, 11 hours ago -
pages print on restart (Win 11 23H2)
by
cyraxote
2 days, 11 hours ago -
Windows 11 Insider Preview build 26200.5581 released to DEV
by
joep517
3 days, 13 hours ago -
Windows 11 Insider Preview build 26120.3950 (24H2) released to BETA
by
joep517
3 days, 13 hours ago -
Proton to drop prices after ruling against “Apple tax”
by
Cybertooth
3 days, 20 hours ago -
24H2 Installer – don’t see Option for non destructive install
by
JP
5 hours, 44 minutes ago
Recent blog posts
Key Links
Want to Advertise in the free newsletter? How about a gift subscription in honor of a birthday? Send an email to sb@askwoody.com to ask how.
Mastodon profile for DefConPatch
Mastodon profile for AskWoody
Home • About • FAQ • Posts & Privacy • Forums • My Account
Register • Free Newsletter • Plus Membership • Gift Certificates • MS-DEFCON Alerts
Copyright ©2004-2025 by AskWoody Tech LLC. All Rights Reserved.