1c46d Extended ListBox query criteria
Sign Up |  Live StatsLive Stats    Articles 37,351| Comments 177,417| Members 19,424, Newest yashpal singh| Online 385
Home Contact
 (Forgotten?): 
    Sikhism
    For best SPN experience, use Firefox Internet Browser!


                                                                   Your Banner Here!    




Click Here to Register/Sign Up Daily Hukamnama Member Blogs Downloads Website Navigation Help Fonts Tags

Extended ListBox query criteria

Our Donation Goal : Why Donate? : Donate Today! : Donate Anonymously (ਗੁਪਤ) : Our Family of Supporters
Goal this month: 500 USD, Received: 115 USD (23%)
Please Donate...
     
Related Topics...
Thread Thread Starter Forum Replies Last Post
Query Field Names AND Captions Rowsource for ListBox Debra Farnham Information Technology 2 28-Jul-2006 08:31 AM
query criteria Chey Information Technology 0 28-Jul-2006 08:27 AM
query criteria Levans digital Information Technology 5 28-Jul-2006 08:25 AM
more than 1 in one query criteria msmuzila@gmail.com Information Technology 0 28-Jul-2006 08:22 AM
query criteria Jessica Information Technology 9 01-Nov-2005 13:40 PM


Tags
extended, listbox, query, criteria
Reply Post New Topic In This Forum Stay Connected to Sikhism, Click Here to Register Now!
  #1 (permalink)  
Old 28-Jul-2006, 08:27 AM
Adam@nospam.com's Avatar Adam@nospam.com
Guest
 
Posts: n/a
   
   
Extended ListBox query criteria

  Donate Today!   Email to Friend  Tell a Friend   Show Printable Version  Print   Contact sikhphilosophy.net Administraion for any Suggestions, Ideas, Feedback.  Feedback  

Register to Remove Advertisements
Hi All,

I have a form 'CSS Search frm' and on the form I've placed a Listbox
'AdvisorList'.

What I would like is to be able to select multiple values from this
listbox and have a query look for the multiple values selected in the
Reference:: Sikh Philosophy Network http://www.sikhphilosophy.net/information-technology/12231-extended-listbox-query-criteria.html
listbox, otherwise if the listbox is blank then dont search for
anything there!

I've got a query 'CSS Case qry' and want to enter such a criteria into
Reference:: Sikh Philosophy Network http://www.sikhphilosophy.net/showthread.php?t=12231
'LoggedBy' field.

Is there a way I can do this using a query criteria?

Help doesnt seem to help me much on this.

Many Thanks!

Adam



Got anything to share on This Topic? Why not share your immediate thoughts/reaction with us! Login Now! or Sign Up Today! to share your views... Gurfateh!
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 28-Jul-2006, 08:27 AM
Brendan Reynolds's Avatar Brendan Reynolds
Guest
 
Posts: n/a
   
   
Re: Extended ListBox query criteria

There's an example of this at the following URL ...

http://www.mvps.org/access/forms/frm0007.htm
Reference:: Sikh Philosophy Network http://www.sikhphilosophy.net/showthread.php?t=12231

--
Brendan Reynolds
Access MVP

"Adam@nospam.com" wrote in message
news:1151489001.638747.210240@x69g2000cwx.googlegr oups.com...
> Hi All,
>
> I have a form 'CSS Search frm' and on the form I've placed a Listbox
> 'AdvisorList'.
>
> What I would like is to be able to select multiple values from this
> listbox and have a query look for the multiple values selected in the
> listbox, otherwise if the listbox is blank then dont search for
Reference:: Sikh Philosophy Network http://www.sikhphilosophy.net/showthread.php?t=12231
> anything there!
>
> I've got a query 'CSS Case qry' and want to enter such a criteria into
> 'LoggedBy' field.
>
> Is there a way I can do this using a query criteria?
>
> Help doesnt seem to help me much on this.
>
> Many Thanks!
>
> Adam
>



Reply With Quote
  #3 (permalink)  
Old 28-Jul-2006, 08:27 AM
Adam@nospam.com's Avatar Adam@nospam.com
Guest
 
Posts: n/a
   
   
Re: Extended ListBox query criteria

Hi Brendan,

I'm not very good with code just yet. I'll try to understand this
though..

Does this go into a module?
Reference:: Sikh Philosophy Network http://www.sikhphilosophy.net/showthread.php?t=12231


Brendan Reynolds wrote:

> There's an example of this at the following URL ...
>
> http://www.mvps.org/access/forms/frm0007.htm
Reference:: Sikh Philosophy Network http://www.sikhphilosophy.net/showthread.php?t=12231
>
> --
> Brendan Reynolds
> Access MVP
>
> "Adam@nospam.com" wrote in message
> news:1151489001.638747.210240@x69g2000cwx.googlegr oups.com...
> > Hi All,
> >
> > I have a form 'CSS Search frm' and on the form I've placed a Listbox
> > 'AdvisorList'.
> >
> > What I would like is to be able to select multiple values from this
> > listbox and have a query look for the multiple values selected in the
> > listbox, otherwise if the listbox is blank then dont search for
> > anything there!
> >
> > I've got a query 'CSS Case qry' and want to enter such a criteria into
> > 'LoggedBy' field.
> >
> > Is there a way I can do this using a query criteria?
> >
> > Help doesnt seem to help me much on this.
> >
> > Many Thanks!
> >
> > Adam
> >


Reply With Quote
  #4 (permalink)  
Old 28-Jul-2006, 08:27 AM
Brendan Reynolds's Avatar Brendan Reynolds
Guest
 
Posts: n/a
   
   
Re: Extended ListBox query criteria

If you expect to call the code from more than one form or report, you could
Reference:: Sikh Philosophy Network http://www.sikhphilosophy.net/showthread.php?t=12231
put it in a public procedure in a standard module. But if you will only call
it from one form or report, you can put it into the module for that form or
report. For example, if you open the query or a report bound to the query by
clicking a command button on the same form that contains the list box, you
could put the code into the Click event of the command button.
Alternatively, if you are opening a report bound to the query, you could put
the code into the Open event of the report.

BTW: There appears to be a slight typo in that example. Where it says 'Set
frm = Form!frmMyForm' I expect the author intended to write 'Set frm =
Reference:: Sikh Philosophy Network http://www.sikhphilosophy.net/showthread.php?t=12231
Forms!frmMyForm' - note 'Forms', plural, not 'Form', singular.

Don't forget to replace the form, listbox, table and field names with your
own names.

I have to go off-line for a while now, but if you can't get it to work, post
a reply to this thread and I'll try to go into a little more detail when I
get back.

--
Brendan Reynolds
Access MVP

"Adam@nospam.com" wrote in message
news:1151490097.875301.141820@p79g2000cwp.googlegr oups.com...
> Hi Brendan,
>
> I'm not very good with code just yet. I'll try to understand this
> though..
>
> Does this go into a module?
>
>
> Brendan Reynolds wrote:
>
>> There's an example of this at the following URL ...
>>
>> http://www.mvps.org/access/forms/frm0007.htm
>>
>> --
>> Brendan Reynolds
>> Access MVP
>>
>> "Adam@nospam.com" wrote in message
>> news:1151489001.638747.210240@x69g2000cwx.googlegr oups.com...
>> > Hi All,
>> >
>> > I have a form 'CSS Search frm' and on the form I've placed a Listbox
>> > 'AdvisorList'.
>> >
>> > What I would like is to be able to select multiple values from this
>> > listbox and have a query look for the multiple values selected in the
>> > listbox, otherwise if the listbox is blank then dont search for
>> > anything there!
>> >
>> > I've got a query 'CSS Case qry' and want to enter such a criteria into
>> > 'LoggedBy' field.
>> >
>> > Is there a way I can do this using a query criteria?
>> >
>> > Help doesnt seem to help me much on this.
>> >
>> > Many Thanks!
>> >
>> > Adam
>> >

>



Reply With Quote
  #5 (permalink)  
Old 28-Jul-2006, 08:28 AM
Adam@nospam.com's Avatar Adam@nospam.com
Guest
 
Posts: n/a
   
   
Re: Extended ListBox query criteria

Ok, how do you put this into your query?

Reference:: Sikh Philosophy Network http://www.sikhphilosophy.net/showthread.php?t=12231
In the query I have other criteria however dont know how to add this
into the existing query?

Also in the code there's a section I dont understand:

strSQL = "Select * from Employees where [EmpID]="

What does Employees link too and what is EmpID referenced too?


Many Thanks

Adam


Brendan Reynolds wrote:

> If you expect to call the code from more than one form or report, you could
> put it in a public procedure in a standard module. But if you will only call
> it from one form or report, you can put it into the module for that form or
> report. For example, if you open the query or a report bound to the query by
> clicking a command button on the same form that contains the list box, you
> could put the code into the Click event of the command button.
> Alternatively, if you are opening a report bound to the query, you could put
> the code into the Open event of the report.
>
> BTW: There appears to be a slight typo in that example. Where it says 'Set
> frm = Form!frmMyForm' I expect the author intended to write 'Set frm =
> Forms!frmMyForm' - note 'Forms', plural, not 'Form', singular.
>
> Don't forget to replace the form, listbox, table and field names with your
Reference:: Sikh Philosophy Network http://www.sikhphilosophy.net/showthread.php?t=12231
> own names.
>
> I have to go off-line for a while now, but if you can't get it to work, post
> a reply to this thread and I'll try to go into a little more detail when I
> get back.
>
> --
> Brendan Reynolds
> Access MVP
>
> "Adam@nospam.com" wrote in message
> news:1151490097.875301.141820@p79g2000cwp.googlegr oups.com...
> > Hi Brendan,
> >
> > I'm not very good with code just yet. I'll try to understand this
> > though..
> >
> > Does this go into a module?
> >
> >
> > Brendan Reynolds wrote:
> >
> >> There's an example of this at the following URL ...
> >>
> >> http://www.mvps.org/access/forms/frm0007.htm
> >>
> >> --
> >> Brendan Reynolds
> >> Access MVP
> >>
> >> "Adam@nospam.com" wrote in message
> >> news:1151489001.638747.210240@x69g2000cwx.googlegr oups.com...
> >> > Hi All,
> >> >
> >> > I have a form 'CSS Search frm' and on the form I've placed a Listbox
> >> > 'AdvisorList'.
> >> >
> >> > What I would like is to be able to select multiple values from this
> >> > listbox and have a query look for the multiple values selected in the
> >> > listbox, otherwise if the listbox is blank then dont search for
> >> > anything there!
> >> >
> >> > I've got a query 'CSS Case qry' and want to enter such a criteria into
> >> > 'LoggedBy' field.
> >> >
> >> > Is there a way I can do this using a query criteria?
> >> >
> >> > Help doesnt seem to help me much on this.
> >> >
> >> > Many Thanks!
> >> >
> >> > Adam
> >> >

> >


Reply With Quote
  #6 (permalink)  
Old 28-Jul-2006, 08:28 AM
Brendan Reynolds's Avatar Brendan Reynolds
Guest
 
Posts: n/a
   
   
Re: Extended ListBox query criteria

Usually, I would not open a query. I would use code like that in the example
to build a SQL string, and assign the SQL string to the Record Source
property of a form or report, or perhaps to the Row Source property of a
combo box or list box. Another Access MVP, Ken Snell, has an example of
using a multi-select combo box (as well as other controls) to filter a form
or report, at the following URL ...

http://www.cadellsoftware.org/SampleDBs.htm#FilterForm

If you really want to open a query directly, though, here's a modification
that would work. Here's the VBA code, that would go in the Click event
procedure of a command button on the same form as the list box ...

Private Sub cmdTest_Click()

Dim ctl As Control
Dim varItem As Variant
Dim strMatch As String

Set ctl = Me.lstTest
If ctl.ItemsSelected.Count > 0 Then
strMatch = ";"
For Each varItem In ctl.ItemsSelected
strMatch = strMatch & ctl.ItemData(varItem) & ";"
Next varItem
Me.txtTest = strMatch
DoCmd.OpenQuery "qryTest"
Else
MsgBox "Please select at least one item from the list."
End If

End Sub

In this example, 'lstTest' is the name of the list box, 'txtTest' is the
Reference:: Sikh Philosophy Network http://www.sikhphilosophy.net/showthread.php?t=12231
name of a text box on the same form (you can hide this text box if you like,
change the Visible property of the check box to 'No' in the Properties
window), and 'qryTest' is the name of the query we want to open.

Here's the SQL from the query ...

SELECT tblTest.*
FROM tblTest
WHERE (((InStr(1,[Forms]![frmTest]![txtTest],";" & [TestText] & ";"))<>0));

I put together a little demo of this which you can find at the following URL
....

http://brenreyn.brinkster.net/multiselectdemo.zip
Reference:: Sikh Philosophy Network http://www.sikhphilosophy.net/showthread.php?t=12231

--
Brendan Reynolds
Access MVP


"Adam@nospam.com" wrote in message
news:1151571007.484087.156170@i40g2000cwc.googlegr oups.com...
> Ok, how do you put this into your query?
>
> In the query I have other criteria however dont know how to add this
> into the existing query?
>
> Also in the code there's a section I dont understand:
>
> strSQL = "Select * from Employees where [EmpID]="
>
> What does Employees link too and what is EmpID referenced too?
>
>
> Many Thanks
>
> Adam
>
>
> Brendan Reynolds wrote:
>
>> If you expect to call the code from more than one form or report, you
>> could
>> put it in a public procedure in a standard module. But if you will only
>> call
>> it from one form or report, you can put it into the module for that form
>> or
>> report. For example, if you open the query or a report bound to the query
>> by
>> clicking a command button on the same form that contains the list box,
>> you
>> could put the code into the Click event of the command button.
>> Alternatively, if you are opening a report bound to the query, you could
>> put
>> the code into the Open event of the report.
>>
>> BTW: There appears to be a slight typo in that example. Where it says
>> 'Set
>> frm = Form!frmMyForm' I expect the author intended to write 'Set frm =
>> Forms!frmMyForm' - note 'Forms', plural, not 'Form', singular.
>>
>> Don't forget to replace the form, listbox, table and field names with
>> your
>> own names.
>>
>> I have to go off-line for a while now, but if you can't get it to work,
>> post
>> a reply to this thread and I'll try to go into a little more detail when
>> I
>> get back.
>>
>> --
>> Brendan Reynolds
>> Access MVP
>>
>> "Adam@nospam.com" wrote in message
>> news:1151490097.875301.141820@p79g2000cwp.googlegr oups.com...
>> > Hi Brendan,
>> >
>> > I'm not very good with code just yet. I'll try to understand this
>> > though..
>> >
>> > Does this go into a module?
>> >
>> >
>> > Brendan Reynolds wrote:
>> >
>> >> There's an example of this at the following URL ...
>> >>
>> >> http://www.mvps.org/access/forms/frm0007.htm
>> >>
>> >> --
>> >> Brendan Reynolds
>> >> Access MVP
>> >>
>> >> "Adam@nospam.com" wrote in message
>> >> news:1151489001.638747.210240@x69g2000cwx.googlegr oups.com...
>> >> > Hi All,
>> >> >
>> >> > I have a form 'CSS Search frm' and on the form I've placed a Listbox
>> >> > 'AdvisorList'.
>> >> >
>> >> > What I would like is to be able to select multiple values from this
>> >> > listbox and have a query look for the multiple values selected in
>> >> > the
>> >> > listbox, otherwise if the listbox is blank then dont search for
>> >> > anything there!
>> >> >
>> >> > I've got a query 'CSS Case qry' and want to enter such a criteria
>> >> > into
>> >> > 'LoggedBy' field.
>> >> >
>> >> > Is there a way I can do this using a query criteria?
>> >> >
>> >> > Help doesnt seem to help me much on this.
>> >> >
>> >> > Many Thanks!
>> >> >
>> >> > Adam
>> >> >
>> >

>



Reply With Quote
  #7 (permalink)  
Old 28-Jul-2006, 08:28 AM
Adam@nospam.com's Avatar Adam@nospam.com
Guest
 
Posts: n/a
   
   
Re: Extended ListBox query criteria

  Donate Today!  
That does the trick!

Thank you!


Brendan Reynolds wrote:

> Usually, I would not open a query. I would use code like that in the example
> to build a SQL string, and assign the SQL string to the Record Source
> property of a form or report, or perhaps to the Row Source property of a
> combo box or list box. Another Access MVP, Ken Snell, has an example of
> using a multi-select combo box (as well as other controls) to filter a form
> or report, at the following URL ...
>
> http://www.cadellsoftware.org/SampleDBs.htm#FilterForm
>
> If you really want to open a query directly, though, here's a modification
> that would work. Here's the VBA code, that would go in the Click event
> procedure of a command button on the same form as the list box ...
>
> Private Sub cmdTest_Click()
>
> Dim ctl As Control
> Dim varItem As Variant
> Dim strMatch As String
>
> Set ctl = Me.lstTest
> If ctl.ItemsSelected.Count > 0 Then
> strMatch = ";"
> For Each varItem In ctl.ItemsSelected
> strMatch = strMatch & ctl.ItemData(varItem) & ";"
> Next varItem
> Me.txtTest = strMatch
> DoCmd.OpenQuery "qryTest"
> Else
> MsgBox "Please select at least one item from the list."
> End If
>
> End Sub
>
> In this example, 'lstTest' is the name of the list box, 'txtTest' is the
> name of a text box on the same form (you can hide this text box if you like,
> change the Visible property of the check box to 'No' in the Properties
> window), and 'qryTest' is the name of the query we want to open.
>
> Here's the SQL from the query ...
>
> SELECT tblTest.*
> FROM tblTest
> WHERE (((InStr(1,[Forms]![frmTest]![txtTest],";" & [TestText] & ";"))<>0));
>
> I put together a little demo of this which you can find at the following URL
> ...
>
> http://brenreyn.brinkster.net/multiselectdemo.zip
>
> --
> Brendan Reynolds
> Access MVP
>
>
> "Adam@nospam.com" wrote in message
> news:1151571007.484087.156170@i40g2000cwc.googlegr oups.com...
> > Ok, how do you put this into your query?
> >
> > In the query I have other criteria however dont know how to add this
> > into the existing query?
> >
> > Also in the code there's a section I dont understand:
> >
> > strSQL = "Select * from Employees where [EmpID]="
> >
> > What does Employees link too and what is EmpID referenced too?
> >
> >
> > Many Thanks
> >
> > Adam
> >
> >
> > Brendan Reynolds wrote:
> >
> >> If you expect to call the code from more than one form or report, you
> >> could
> >> put it in a public procedure in a standard module. But if you will only
> >> call
> >> it from one form or report, you can put it into the module for that form
> >> or
> >> report. For example, if you open the query or a report bound to the query
Reference:: Sikh Philosophy Network http://www.sikhphilosophy.net/showthread.php?t=12231
> >> by
> >> clicking a command button on the same form that contains the list box,
> >> you
> >> could put the code into the Click event of the command button.
> >> Alternatively, if you are opening a report bound to the query, you could
> >> put
> >> the code into the Open event of the report.
> >>
> >> BTW: There appears to be a slight typo in that example. Where it says
Reference:: Sikh Philosophy Network http://www.sikhphilosophy.net/showthread.php?t=12231
> >> 'Set
> >> frm = Form!frmMyForm' I expect the author intended to write 'Set frm =
> >> Forms!frmMyForm' - note 'Forms', plural, not 'Form', singular.
> >>
> >> Don't forget to replace the form, listbox, table and field names with
> >> your
> >> own names.
> >>
> >> I have to go off-line for a while now, but if you can't get it to work,
> >> post
> >> a reply to this thread and I'll try to go into a little more detail when
> >> I
> >> get back.
> >>
> >> --
> >> Brendan Reynolds
> >> Access MVP
> >>
> >> "Adam@nospam.com" wrote in message
> >> news:1151490097.875301.141820@p79g2000cwp.googlegr oups.com...
> >> > Hi Brendan,
> >> >
> >> > I'm not very good with code just yet. I'll try to understand this
> >> > though..
> >> >
> >> > Does this go into a module?
> >> >
> >> >
> >> > Brendan Reynolds wrote:
> >> >
> >> >> There's an example of this at the following URL ...
> >> >>
> >> >> http://www.mvps.org/access/forms/frm0007.htm
> >> >>
> >> >> --
> >> >> Brendan Reynolds
> >> >> Access MVP
> >> >>
> >> >> "Adam@nospam.com" wrote in message
> >> >> news:1151489001.638747.210240@x69g2000cwx.googlegr oups.com...
> >> >> > Hi All,
> >> >> >
> >> >> > I have a form 'CSS Search frm' and on the form I've placed a Listbox
> >> >> > 'AdvisorList'.
> >> >> >
> >> >> > What I would like is to be able to select multiple values from this
> >> >> > listbox and have a query look for the multiple values selected in
> >> >> > the
> >> >> > listbox, otherwise if the listbox is blank then dont search for
> >> >> > anything there!
> >> >> >
> >> >> > I've got a query 'CSS Case qry' and want to enter such a criteria
> >> >> > into
> >> >> > 'LoggedBy' field.
> >> >> >
> >> >> > Is there a way I can do this using a query criteria?
> >> >> >
> >> >> > Help doesnt seem to help me much on this.
> >> >> >
> >> >> > Many Thanks!
> >> >> >
> >> >> > Adam
> >> >> >
> >> >

> >


Reply With Quote
   Click Here to Donate Now!

Support Us!
Become a Promoter!
Gurfateh ji, you can become a SPN Promoter by Donating as little as $10 each month. With limited resources & high operational costs, your donations make it possible for us to deliver a quality website and spread the teachings of the Sri Guru Granth Sahib Ji, to serve & uplift humanity. Every contribution counts. Donate Generously. Gurfateh!
ReplyPost New Topic In This Forum Stay Connected to Sikhism, Click Here to Register Now!

Bookmarks


(View-All Members who have read this thread : 0
There are no names to display.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Tools Search
Search:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On
Trackbacks are On
Pingbacks are On
Refbacks are On

» Active Discussions
Is Science a Religion?
Today 07:47 AM
18 Replies, 2,075 Views
UNITED SIKHS AID Team...
Today 03:19 AM
0 Replies, 31 Views
Woolwich Killing: The...
Today 03:05 AM
26 Replies, 291 Views
Abu Nusaybah, 'Friend'...
Today 02:33 AM
0 Replies, 44 Views
Stockholm riots throw...
Today 02:14 AM
10 Replies, 106 Views
How does Sikhi help you...
Today 02:04 AM
48 Replies, 1,225 Views
Sikh Spokesman (ਪੰਜਾਬੀ...
Today 01:52 AM
186 Replies, 4,659 Views
Rozana Reports (ਪੰਜਾਬੀ...
Today 01:41 AM
322 Replies, 7,737 Views
Paneer: what I have...
Yesterday 22:29 PM
8 Replies, 81 Views
How Many Sikhs Have...
Yesterday 21:55 PM
698 Replies, 51,741 Views
Transgenderism ... Right...
By Kaylee
Yesterday 17:55 PM
31 Replies, 1,385 Views
Rochester Gurdwara...
Yesterday 10:55 AM
2 Replies, 85 Views
US Congress panel passes...
Yesterday 04:22 AM
0 Replies, 50 Views
Harmeet Kaur Took the...
Yesterday 03:40 AM
0 Replies, 71 Views
Panjabi Alphabet Resource
24-May-2013 23:15 PM
12 Replies, 6,566 Views
» Books You Should Read...
Powered by vBadvanced CMPS v3.2.3
All times are GMT +6.5. The time now is 08:17 AM.
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2013, vBulletin Solutions, Inc.
Search Engine Optimization by vBSEO 3.6.0 PL2 Copyright © 2004-12, All Rights Reserved. Sikh Philosophy Network


Page generated in 0.96170 seconds with 32 queries
0