Go Back   Access World Forums > Microsoft Access Discussion > Queries

 
Reply
 
Thread Tools Rate Thread Display Modes
Old 02-12-2019, 08:05 AM   #46
pbaldy
Wino Moderator
 
pbaldy's Avatar
 
Join Date: Aug 2003
Location: Nevada, USA
Posts: 33,372
Thanks: 13
Thanked 4,120 Times in 4,052 Posts
pbaldy is a splendid one to behold pbaldy is a splendid one to behold pbaldy is a splendid one to behold pbaldy is a splendid one to behold pbaldy is a splendid one to behold pbaldy is a splendid one to behold pbaldy is a splendid one to behold pbaldy is a splendid one to behold
Re: Multi-Select Listbox as filter for Query field

This would be more efficient, but the second method would work with DLookup too:

http://www.baldyweb.com/Autofill.htm

__________________
Paul
Microsoft Access MVP 2007-2019

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
pbaldy is offline   Reply With Quote
Old 02-15-2019, 01:52 AM   #47
irsmalik
Newly Registered User
 
Join Date: Jan 2015
Location: Multan - Pakistan
Posts: 45
Thanks: 0
Thanked 0 Times in 0 Posts
irsmalik is on a distinguished road
Send a message via Skype™ to irsmalik
Re: Multi-Select Listbox as filter for Query field

Dear Sir Pbaldy
I have check multi select your web page

Set ctl = Me.lstEmployees
For Each varItem In ctl.ItemsSelected
rs.AddNew
rs!EmpID = ctl.ItemData(varItem)
rs!OtherValue = Me.txtOtherValue
rs.Update
Next varItem

*************
Plz guide me if I want to add 1 more item in this list like
rs!EmpID = ctl.ItemData(varItem) and
rs!EmpName = ctl.ItemData(varItem)..

Thanks
irsmalik
irsmalik is offline   Reply With Quote
Old 02-15-2019, 08:34 AM   #48
pbaldy
Wino Moderator
 
pbaldy's Avatar
 
Join Date: Aug 2003
Location: Nevada, USA
Posts: 33,372
Thanks: 13
Thanked 4,120 Times in 4,052 Posts
pbaldy is a splendid one to behold pbaldy is a splendid one to behold pbaldy is a splendid one to behold pbaldy is a splendid one to behold pbaldy is a splendid one to behold pbaldy is a splendid one to behold pbaldy is a splendid one to behold pbaldy is a splendid one to behold
Re: Multi-Select Listbox as filter for Query field

This type of thing:

ctl.Column(x, varItem) use this if you need columns

where x is the zero-based column number containing the desired value.

__________________
Paul
Microsoft Access MVP 2007-2019

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
pbaldy is offline   Reply With Quote
Old 02-15-2019, 06:40 PM   #49
dhawan_aj
Newly Registered User
 
Join Date: Feb 2019
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
dhawan_aj is on a distinguished road
Re: Multi-Select Listbox as filter for Query field

Sir I need help for the below query

I need you help in Microsoft Access to fix one query.


IN/OUT LOADED/EMPTY TRAILER DATE & TIME
IN LOADED 456667 2/10/2019 1:12:00 PM
IN EMPTY 53004 2/11/2019 2:00:00 PM
IN LOADED 53005 2/10/2019 2:35:00 PM
OUT LOADED 53005 2/10/2019 1:00:00 PM
IN EMPTY 53006 2/11/2019 10:35:00 AM
IN LOADED 53665 2/9/2019 4:00:00 PM
OUT LOADED 54334 2/10/2019 3:10:00 PM

I need only those entries that have "IN" and if under "Trailer" section have 2 same number then only those
come in the result whoever have greater "Date & time" and if "Out" is greater than I don't need that entry.

Please advise how I can get those results in the query. "HELP ME"
Attached Images
dhawan_aj is offline   Reply With Quote
Old 02-15-2019, 10:57 PM   #50
irsmalik
Newly Registered User
 
Join Date: Jan 2015
Location: Multan - Pakistan
Posts: 45
Thanks: 0
Thanked 0 Times in 0 Posts
irsmalik is on a distinguished road
Send a message via Skype™ to irsmalik
Re: Multi-Select Listbox as filter for Query field

Sir PBaldy
Sorry I could not understand your line. kindly correct below lines as per your idea. Purpose is to append / update record.

Set ctl = Me.lstEmployees
For Each varItem In ctl.ItemsSelected
rs.AddNew
rs!EmpID = ctl.ItemData(varItem) Also want to Add EMP Name, Phone etc.
rs!OtherValue = Me.txtOtherValue
rs.Update
Next varItem
Thanks
irsmalik
irsmalik is offline   Reply With Quote
Old 02-16-2019, 08:41 AM   #51
pbaldy
Wino Moderator
 
pbaldy's Avatar
 
Join Date: Aug 2003
Location: Nevada, USA
Posts: 33,372
Thanks: 13
Thanked 4,120 Times in 4,052 Posts
pbaldy is a splendid one to behold pbaldy is a splendid one to behold pbaldy is a splendid one to behold pbaldy is a splendid one to behold pbaldy is a splendid one to behold pbaldy is a splendid one to behold pbaldy is a splendid one to behold pbaldy is a splendid one to behold
Re: Multi-Select Listbox as filter for Query field

Like:

rs!EmpName = ctl.ItemData(1, varItem)
__________________
Paul
Microsoft Access MVP 2007-2019

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
pbaldy is offline   Reply With Quote
Old 02-17-2019, 08:57 PM   #52
irsmalik
Newly Registered User
 
Join Date: Jan 2015
Location: Multan - Pakistan
Posts: 45
Thanks: 0
Thanked 0 Times in 0 Posts
irsmalik is on a distinguished road
Send a message via Skype™ to irsmalik
Re: Multi-Select Listbox as filter for Query field

No Sir... Pbaldy............ it is giving compile error... Plz see the attached picture.
My purpose is to Add
EmpID
EMPLName
EMPFName

thanks
irsmalik
Attached Images
File Type: jpg pcture.jpg (93.4 KB, 14 views)

irsmalik is offline   Reply With Quote
Old 02-17-2019, 09:59 PM   #53
pbaldy
Wino Moderator
 
pbaldy's Avatar
 
Join Date: Aug 2003
Location: Nevada, USA
Posts: 33,372
Thanks: 13
Thanked 4,120 Times in 4,052 Posts
pbaldy is a splendid one to behold pbaldy is a splendid one to behold pbaldy is a splendid one to behold pbaldy is a splendid one to behold pbaldy is a splendid one to behold pbaldy is a splendid one to behold pbaldy is a splendid one to behold pbaldy is a splendid one to behold
Re: Multi-Select Listbox as filter for Query field

Oops, try

ctl.Column(1, varItem)

You need to specify each of the field names of course.
__________________
Paul
Microsoft Access MVP 2007-2019

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
pbaldy is offline   Reply With Quote
Old 02-17-2019, 11:51 PM   #54
irsmalik
Newly Registered User
 
Join Date: Jan 2015
Location: Multan - Pakistan
Posts: 45
Thanks: 0
Thanked 0 Times in 0 Posts
irsmalik is on a distinguished road
Send a message via Skype™ to irsmalik
Re: Multi-Select Listbox as filter for Query field

Sir what would be the exact line
ctl.Column(1, varItem)

?
irsmalik
irsmalik is offline   Reply With Quote
Old 02-18-2019, 07:58 AM   #55
pbaldy
Wino Moderator
 
pbaldy's Avatar
 
Join Date: Aug 2003
Location: Nevada, USA
Posts: 33,372
Thanks: 13
Thanked 4,120 Times in 4,052 Posts
pbaldy is a splendid one to behold pbaldy is a splendid one to behold pbaldy is a splendid one to behold pbaldy is a splendid one to behold pbaldy is a splendid one to behold pbaldy is a splendid one to behold pbaldy is a splendid one to behold pbaldy is a splendid one to behold
Re: Multi-Select Listbox as filter for Query field

rs!FieldName = ctl.Column(1, varItem)
__________________
Paul
Microsoft Access MVP 2007-2019

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
pbaldy is offline   Reply With Quote
Old 02-18-2019, 09:06 PM   #56
irsmalik
Newly Registered User
 
Join Date: Jan 2015
Location: Multan - Pakistan
Posts: 45
Thanks: 0
Thanked 0 Times in 0 Posts
irsmalik is on a distinguished road
Send a message via Skype™ to irsmalik
Re: Multi-Select Listbox as filter for Query field

No Sir Pbaldy........ this is your suggested line

rs!FieldName = ctl.Column(1, varItem)

Below is my line......... I think I am making some mistake.....
rs!EmpName = ctl.ItemData(1, varItem)

Please see the attached picture for code and its error message. My Selection form is also shown in this picture.

Thanks
irsmalik
Attached Images
File Type: jpg picture.jpg (91.0 KB, 6 views)
irsmalik is offline   Reply With Quote
Old 02-18-2019, 09:32 PM   #57
pbaldy
Wino Moderator
 
pbaldy's Avatar
 
Join Date: Aug 2003
Location: Nevada, USA
Posts: 33,372
Thanks: 13
Thanked 4,120 Times in 4,052 Posts
pbaldy is a splendid one to behold pbaldy is a splendid one to behold pbaldy is a splendid one to behold pbaldy is a splendid one to behold pbaldy is a splendid one to behold pbaldy is a splendid one to behold pbaldy is a splendid one to behold pbaldy is a splendid one to behold
Re: Multi-Select Listbox as filter for Query field

Try using Column instead of ItemData, as shown in post 55.
__________________
Paul
Microsoft Access MVP 2007-2019

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
pbaldy is offline   Reply With Quote
Old 02-18-2019, 11:29 PM   #58
irsmalik
Newly Registered User
 
Join Date: Jan 2015
Location: Multan - Pakistan
Posts: 45
Thanks: 0
Thanked 0 Times in 0 Posts
irsmalik is on a distinguished road
Send a message via Skype™ to irsmalik
Re: Multi-Select Listbox as filter for Query field

Thank You so Sir Pbdaldy...

Now it is working..... I realize... I call you again & again... but believe me... I learn a lot from you.

Once again Thank You.
irsmalik
irsmalik is offline   Reply With Quote
Old 02-19-2019, 08:50 AM   #59
pbaldy
Wino Moderator
 
pbaldy's Avatar
 
Join Date: Aug 2003
Location: Nevada, USA
Posts: 33,372
Thanks: 13
Thanked 4,120 Times in 4,052 Posts
pbaldy is a splendid one to behold pbaldy is a splendid one to behold pbaldy is a splendid one to behold pbaldy is a splendid one to behold pbaldy is a splendid one to behold pbaldy is a splendid one to behold pbaldy is a splendid one to behold pbaldy is a splendid one to behold
Re: Multi-Select Listbox as filter for Query field

No problem!
__________________
Paul
Microsoft Access MVP 2007-2019

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
pbaldy is offline   Reply With Quote
Old 02-19-2019, 12:58 PM   #60
kb44
Newly Registered User
 
Join Date: Dec 2018
Posts: 44
Thanks: 34
Thanked 0 Times in 0 Posts
kb44 is on a distinguished road
Re: Multi-Select Listbox as filter for Query field

I just read this thread and wow.. I give much praise @pbaldy for trying so hard to help someone even though his help requests seemed like demands at times.

There is clearly a language barrier and that seemed to be the reason.

It did not phase pbaldy. You are a VIP sir!

kb44 is offline   Reply With Quote
Reply

Tags
listbox , multi-select , query

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Use Records in Multi Select Listbox in query TimTDP Modules & VBA 2 09-19-2012 08:33 AM
Filter Report based on Multi-Select Listbox bstboy Forms 3 10-24-2011 05:42 AM
Filter query by multi select listbox AccessDev Forms 3 09-02-2006 11:51 AM
Multi Select ListBox criteria in query oihjk Forms 1 04-01-2003 03:58 PM
[SOLVED] Using a Multi-select listbox to populate a DB field mackdaddy Forms 1 07-10-2000 02:48 PM




All times are GMT -8. The time now is 01:26 PM.


Microsoft Access Help
General
Tables
Queries
Forms
Reports
Macros
Modules & VBA
Theory & Practice
Access FAQs
Code Repository
Sample Databases
Video Tutorials

Featured Forum post


Sponsored Links


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
(c) copyright 2017 Access World