Combo Box - Multiple Selections

G

Guest

Is there a way to make a Combo Box accept multiple selections?

I have a table that has look-up values for two fields, and I want users to
be able to print a report with more than one of these options.

If anyone has any suggestions about how to do this I would appreciate it.
 
G

Guest

Well I guess now the question is how do I use the ItemSelected property in
the query?
 
D

Douglas J Steele

Combo boxes do not allow more than one selection. End of discussion.

Only List boxes allow you to make more than one selection (and not by
default: you have to set the control's MultiSelect property to either Simple
or Extended).

If by "how do I use the ItemSelected property in the query?" you mean is
there some way for a query to refer to a list box set for MultiSelect and
use what's selected as its criteria, the answer is no, at least, not
directly.

http://www.mvps.org/access/forms/frm0007.htm at "The Access Web" shows one
way how you can alter the SQL associated with a query to accept
multiselected items from a list box, although to be honest, I prefer:

Dim frm As Form, ctl As Control
Dim varItem As Variant
Dim strSQL As String

Set frm = Form!frmMyForm
Set ctl = frm!lbMultiSelectListbox

If ctl.ItemsSelected.Count > 0 Then
strSQL = "Select * from Employees where [EmpID] IN ("
For Each varItem In ctl.ItemsSelected
strSQL = strSQL & ctl.ItemData(varItem) & ", "
Next varItem

strSQL=Left$(strSQL,Len(strSQL)-2)) & ")"
End If
 
G

Guest

Would this code go into the AfterUpdate event or somewhere else?
--
Never give up, the answer IS out there, it just takes a while to find it
sometimes!


Douglas J Steele said:
Combo boxes do not allow more than one selection. End of discussion.

Only List boxes allow you to make more than one selection (and not by
default: you have to set the control's MultiSelect property to either Simple
or Extended).

If by "how do I use the ItemSelected property in the query?" you mean is
there some way for a query to refer to a list box set for MultiSelect and
use what's selected as its criteria, the answer is no, at least, not
directly.

http://www.mvps.org/access/forms/frm0007.htm at "The Access Web" shows one
way how you can alter the SQL associated with a query to accept
multiselected items from a list box, although to be honest, I prefer:

Dim frm As Form, ctl As Control
Dim varItem As Variant
Dim strSQL As String

Set frm = Form!frmMyForm
Set ctl = frm!lbMultiSelectListbox

If ctl.ItemsSelected.Count > 0 Then
strSQL = "Select * from Employees where [EmpID] IN ("
For Each varItem In ctl.ItemsSelected
strSQL = strSQL & ctl.ItemData(varItem) & ", "
Next varItem

strSQL=Left$(strSQL,Len(strSQL)-2)) & ")"
End If




--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)
 
D

Douglas J Steele

Since the AfterUpdate event will occur with each selection, you're best off
having a button for the user to click on when they've finished making
selections, and put the code in that button's Click event.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Larry G. said:
Would this code go into the AfterUpdate event or somewhere else?
--
Never give up, the answer IS out there, it just takes a while to find it
sometimes!


Douglas J Steele said:
Combo boxes do not allow more than one selection. End of discussion.

Only List boxes allow you to make more than one selection (and not by
default: you have to set the control's MultiSelect property to either Simple
or Extended).

If by "how do I use the ItemSelected property in the query?" you mean is
there some way for a query to refer to a list box set for MultiSelect and
use what's selected as its criteria, the answer is no, at least, not
directly.

http://www.mvps.org/access/forms/frm0007.htm at "The Access Web" shows one
way how you can alter the SQL associated with a query to accept
multiselected items from a list box, although to be honest, I prefer:

Dim frm As Form, ctl As Control
Dim varItem As Variant
Dim strSQL As String

Set frm = Form!frmMyForm
Set ctl = frm!lbMultiSelectListbox

If ctl.ItemsSelected.Count > 0 Then
strSQL = "Select * from Employees where [EmpID] IN ("
For Each varItem In ctl.ItemsSelected
strSQL = strSQL & ctl.ItemData(varItem) & ", "
Next varItem

strSQL=Left$(strSQL,Len(strSQL)-2)) & ")"
End If




--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Larry G. said:
Well I guess now the question is how do I use the ItemSelected property in
the query?
--
Never give up, the answer IS out there, it just takes a while to find it
sometimes!


:

Is there a way to make a Combo Box accept multiple selections?

I have a table that has look-up values for two fields, and I want
users
to
be able to print a report with more than one of these options.

If anyone has any suggestions about how to do this I would
appreciate
it.
 
G

Guest

Thanks for the info - it does the trick!

My other problem then is how do I get the query to reference what is in the
invisble text box? Since it is a complete SQL statement?
--
Never give up, the answer IS out there, it just takes a while to find it
sometimes!


Douglas J Steele said:
Since the AfterUpdate event will occur with each selection, you're best off
having a button for the user to click on when they've finished making
selections, and put the code in that button's Click event.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Larry G. said:
Would this code go into the AfterUpdate event or somewhere else?
--
Never give up, the answer IS out there, it just takes a while to find it
sometimes!


Douglas J Steele said:
Combo boxes do not allow more than one selection. End of discussion.

Only List boxes allow you to make more than one selection (and not by
default: you have to set the control's MultiSelect property to either Simple
or Extended).

If by "how do I use the ItemSelected property in the query?" you mean is
there some way for a query to refer to a list box set for MultiSelect and
use what's selected as its criteria, the answer is no, at least, not
directly.

http://www.mvps.org/access/forms/frm0007.htm at "The Access Web" shows one
way how you can alter the SQL associated with a query to accept
multiselected items from a list box, although to be honest, I prefer:

Dim frm As Form, ctl As Control
Dim varItem As Variant
Dim strSQL As String

Set frm = Form!frmMyForm
Set ctl = frm!lbMultiSelectListbox

If ctl.ItemsSelected.Count > 0 Then
strSQL = "Select * from Employees where [EmpID] IN ("
For Each varItem In ctl.ItemsSelected
strSQL = strSQL & ctl.ItemData(varItem) & ", "
Next varItem

strSQL=Left$(strSQL,Len(strSQL)-2)) & ")"
End If




--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Well I guess now the question is how do I use the ItemSelected property in
the query?
--
Never give up, the answer IS out there, it just takes a while to find it
sometimes!


:

Is there a way to make a Combo Box accept multiple selections?

I have a table that has look-up values for two fields, and I want users
to
be able to print a report with more than one of these options.

If anyone has any suggestions about how to do this I would appreciate
it.
 
D

Douglas J Steele

Whether or not a control is hidden doesn't change how you refer to it.

However, having said that, I'm not quite sure what Dev had in mind when he
said you could manually assign the complete WHERE clause to a hidden
control.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Larry G. said:
Thanks for the info - it does the trick!

My other problem then is how do I get the query to reference what is in the
invisble text box? Since it is a complete SQL statement?
--
Never give up, the answer IS out there, it just takes a while to find it
sometimes!


Douglas J Steele said:
Since the AfterUpdate event will occur with each selection, you're best off
having a button for the user to click on when they've finished making
selections, and put the code in that button's Click event.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Larry G. said:
Would this code go into the AfterUpdate event or somewhere else?
--
Never give up, the answer IS out there, it just takes a while to find it
sometimes!


:

Combo boxes do not allow more than one selection. End of discussion.

Only List boxes allow you to make more than one selection (and not by
default: you have to set the control's MultiSelect property to
either
Simple
or Extended).

If by "how do I use the ItemSelected property in the query?" you mean is
there some way for a query to refer to a list box set for
MultiSelect
and
use what's selected as its criteria, the answer is no, at least, not
directly.

http://www.mvps.org/access/forms/frm0007.htm at "The Access Web"
shows
one
way how you can alter the SQL associated with a query to accept
multiselected items from a list box, although to be honest, I prefer:

Dim frm As Form, ctl As Control
Dim varItem As Variant
Dim strSQL As String

Set frm = Form!frmMyForm
Set ctl = frm!lbMultiSelectListbox

If ctl.ItemsSelected.Count > 0 Then
strSQL = "Select * from Employees where [EmpID] IN ("
For Each varItem In ctl.ItemsSelected
strSQL = strSQL & ctl.ItemData(varItem) & ", "
Next varItem

strSQL=Left$(strSQL,Len(strSQL)-2)) & ")"
End If




--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Well I guess now the question is how do I use the ItemSelected property in
the query?
find
it
sometimes!


:

Is there a way to make a Combo Box accept multiple selections?

I have a table that has look-up values for two fields, and I
want
users
to
be able to print a report with more than one of these options.

If anyone has any suggestions about how to do this I would appreciate
it.
 
G

Guest

Right, I got that too. My question is: How do I create the query then to USE
what is in that text box, where do I put the
"[Forms]![frmMyForm]![txtTextBox] reference?
--
Never give up, the answer IS out there, it just takes a while to find it
sometimes!


Douglas J Steele said:
Whether or not a control is hidden doesn't change how you refer to it.

However, having said that, I'm not quite sure what Dev had in mind when he
said you could manually assign the complete WHERE clause to a hidden
control.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Larry G. said:
Thanks for the info - it does the trick!

My other problem then is how do I get the query to reference what is in the
invisble text box? Since it is a complete SQL statement?
--
Never give up, the answer IS out there, it just takes a while to find it
sometimes!


Douglas J Steele said:
Since the AfterUpdate event will occur with each selection, you're best off
having a button for the user to click on when they've finished making
selections, and put the code in that button's Click event.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Would this code go into the AfterUpdate event or somewhere else?
--
Never give up, the answer IS out there, it just takes a while to find it
sometimes!


:

Combo boxes do not allow more than one selection. End of discussion.

Only List boxes allow you to make more than one selection (and not by
default: you have to set the control's MultiSelect property to either
Simple
or Extended).

If by "how do I use the ItemSelected property in the query?" you mean is
there some way for a query to refer to a list box set for MultiSelect
and
use what's selected as its criteria, the answer is no, at least, not
directly.

http://www.mvps.org/access/forms/frm0007.htm at "The Access Web" shows
one
way how you can alter the SQL associated with a query to accept
multiselected items from a list box, although to be honest, I prefer:

Dim frm As Form, ctl As Control
Dim varItem As Variant
Dim strSQL As String

Set frm = Form!frmMyForm
Set ctl = frm!lbMultiSelectListbox

If ctl.ItemsSelected.Count > 0 Then
strSQL = "Select * from Employees where [EmpID] IN ("
For Each varItem In ctl.ItemsSelected
strSQL = strSQL & ctl.ItemData(varItem) & ", "
Next varItem

strSQL=Left$(strSQL,Len(strSQL)-2)) & ")"
End If




--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Well I guess now the question is how do I use the ItemSelected
property in
the query?
--
Never give up, the answer IS out there, it just takes a while to find
it
sometimes!


:

Is there a way to make a Combo Box accept multiple selections?

I have a table that has look-up values for two fields, and I want
users
to
be able to print a report with more than one of these options.

If anyone has any suggestions about how to do this I would
appreciate
it.
 
D

Douglas J Steele

That's what I'm trying to say: I don't understand what Dev meant when he
said you could. I can't think of how you'd do it...

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Larry G. said:
Right, I got that too. My question is: How do I create the query then to USE
what is in that text box, where do I put the
"[Forms]![frmMyForm]![txtTextBox] reference?
--
Never give up, the answer IS out there, it just takes a while to find it
sometimes!


Douglas J Steele said:
Whether or not a control is hidden doesn't change how you refer to it.

However, having said that, I'm not quite sure what Dev had in mind when he
said you could manually assign the complete WHERE clause to a hidden
control.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Larry G. said:
Thanks for the info - it does the trick!

My other problem then is how do I get the query to reference what is
in
the
invisble text box? Since it is a complete SQL statement?
--
Never give up, the answer IS out there, it just takes a while to find it
sometimes!


:

Since the AfterUpdate event will occur with each selection, you're
best
off
having a button for the user to click on when they've finished making
selections, and put the code in that button's Click event.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Would this code go into the AfterUpdate event or somewhere else?
find
it
sometimes!


:

Combo boxes do not allow more than one selection. End of discussion.

Only List boxes allow you to make more than one selection (and
not
by
default: you have to set the control's MultiSelect property to either
Simple
or Extended).

If by "how do I use the ItemSelected property in the query?" you mean is
there some way for a query to refer to a list box set for MultiSelect
and
use what's selected as its criteria, the answer is no, at least, not
directly.

http://www.mvps.org/access/forms/frm0007.htm at "The Access Web" shows
one
way how you can alter the SQL associated with a query to accept
multiselected items from a list box, although to be honest, I prefer:

Dim frm As Form, ctl As Control
Dim varItem As Variant
Dim strSQL As String

Set frm = Form!frmMyForm
Set ctl = frm!lbMultiSelectListbox

If ctl.ItemsSelected.Count > 0 Then
strSQL = "Select * from Employees where [EmpID] IN ("
For Each varItem In ctl.ItemsSelected
strSQL = strSQL & ctl.ItemData(varItem) & ", "
Next varItem

strSQL=Left$(strSQL,Len(strSQL)-2)) & ")"
End If




--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Well I guess now the question is how do I use the ItemSelected
property in
the query?
to
find
it
sometimes!


:

Is there a way to make a Combo Box accept multiple selections?

I have a table that has look-up values for two fields, and I want
users
to
be able to print a report with more than one of these options.

If anyone has any suggestions about how to do this I would
appreciate
it.
 
G

Guest

LOL - OK thanks! I am taking a different approach anyway now - I think I am
going to try for the parameter in the query "Like
[Forms]![MyForm]![txtParameter], and have the value of the parameter read
"*Parameter1*" OR "Parameter2"

--
Never give up, the answer IS out there, it just takes a while to find it
sometimes!


Douglas J Steele said:
That's what I'm trying to say: I don't understand what Dev meant when he
said you could. I can't think of how you'd do it...

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Larry G. said:
Right, I got that too. My question is: How do I create the query then to USE
what is in that text box, where do I put the
"[Forms]![frmMyForm]![txtTextBox] reference?
--
Never give up, the answer IS out there, it just takes a while to find it
sometimes!


Douglas J Steele said:
Whether or not a control is hidden doesn't change how you refer to it.

However, having said that, I'm not quite sure what Dev had in mind when he
said you could manually assign the complete WHERE clause to a hidden
control.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Thanks for the info - it does the trick!

My other problem then is how do I get the query to reference what is in
the
invisble text box? Since it is a complete SQL statement?
--
Never give up, the answer IS out there, it just takes a while to find it
sometimes!


:

Since the AfterUpdate event will occur with each selection, you're best
off
having a button for the user to click on when they've finished making
selections, and put the code in that button's Click event.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Would this code go into the AfterUpdate event or somewhere else?
--
Never give up, the answer IS out there, it just takes a while to find
it
sometimes!


:

Combo boxes do not allow more than one selection. End of discussion.

Only List boxes allow you to make more than one selection (and not
by
default: you have to set the control's MultiSelect property to
either
Simple
or Extended).

If by "how do I use the ItemSelected property in the query?" you
mean is
there some way for a query to refer to a list box set for
MultiSelect
and
use what's selected as its criteria, the answer is no, at least, not
directly.

http://www.mvps.org/access/forms/frm0007.htm at "The Access Web"
shows
one
way how you can alter the SQL associated with a query to accept
multiselected items from a list box, although to be honest, I
prefer:

Dim frm As Form, ctl As Control
Dim varItem As Variant
Dim strSQL As String

Set frm = Form!frmMyForm
Set ctl = frm!lbMultiSelectListbox

If ctl.ItemsSelected.Count > 0 Then
strSQL = "Select * from Employees where [EmpID] IN ("
For Each varItem In ctl.ItemsSelected
strSQL = strSQL & ctl.ItemData(varItem) & ", "
Next varItem

strSQL=Left$(strSQL,Len(strSQL)-2)) & ")"
End If




--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Well I guess now the question is how do I use the ItemSelected
property in
the query?
--
Never give up, the answer IS out there, it just takes a while to
find
it
sometimes!


:

Is there a way to make a Combo Box accept multiple selections?

I have a table that has look-up values for two fields, and I
want
users
to
be able to print a report with more than one of these options.

If anyone has any suggestions about how to do this I would
appreciate
it.
 
D

Douglas J Steele

Unfortunately, that won't work.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Larry G. said:
LOL - OK thanks! I am taking a different approach anyway now - I think I am
going to try for the parameter in the query "Like
[Forms]![MyForm]![txtParameter], and have the value of the parameter read
"*Parameter1*" OR "Parameter2"

--
Never give up, the answer IS out there, it just takes a while to find it
sometimes!


Douglas J Steele said:
That's what I'm trying to say: I don't understand what Dev meant when he
said you could. I can't think of how you'd do it...

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Larry G. said:
Right, I got that too. My question is: How do I create the query then
to
USE
what is in that text box, where do I put the
"[Forms]![frmMyForm]![txtTextBox] reference?
--
Never give up, the answer IS out there, it just takes a while to find it
sometimes!


:

Whether or not a control is hidden doesn't change how you refer to it.

However, having said that, I'm not quite sure what Dev had in mind
when
he
said you could manually assign the complete WHERE clause to a hidden
control.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Thanks for the info - it does the trick!

My other problem then is how do I get the query to reference what
is
in
the
invisble text box? Since it is a complete SQL statement?
find
it
sometimes!


:

Since the AfterUpdate event will occur with each selection,
you're
best
off
having a button for the user to click on when they've finished making
selections, and put the code in that button's Click event.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Would this code go into the AfterUpdate event or somewhere else?
to
find
it
sometimes!


:

Combo boxes do not allow more than one selection. End of discussion.

Only List boxes allow you to make more than one selection
(and
not
by
default: you have to set the control's MultiSelect property to
either
Simple
or Extended).

If by "how do I use the ItemSelected property in the query?" you
mean is
there some way for a query to refer to a list box set for
MultiSelect
and
use what's selected as its criteria, the answer is no, at
least,
not
directly.

http://www.mvps.org/access/forms/frm0007.htm at "The Access Web"
shows
one
way how you can alter the SQL associated with a query to accept
multiselected items from a list box, although to be honest, I
prefer:

Dim frm As Form, ctl As Control
Dim varItem As Variant
Dim strSQL As String

Set frm = Form!frmMyForm
Set ctl = frm!lbMultiSelectListbox

If ctl.ItemsSelected.Count > 0 Then
strSQL = "Select * from Employees where [EmpID] IN ("
For Each varItem In ctl.ItemsSelected
strSQL = strSQL & ctl.ItemData(varItem) & ", "
Next varItem

strSQL=Left$(strSQL,Len(strSQL)-2)) & ")"
End If




--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Well I guess now the question is how do I use the ItemSelected
property in
the query?
while
to
find
it
sometimes!


:

Is there a way to make a Combo Box accept multiple selections?

I have a table that has look-up values for two fields, and I
want
users
to
be able to print a report with more than one of these options.

If anyone has any suggestions about how to do this I would
appreciate
it.
 
G

Guest

I may not have explained it correctly, but it does work the way I envisioned
it. I had to add a second invisible text box, named txtParam2, and then added
an OR line in the query to look at what is in there, if it is null, it only
returns what is in the txtParam1 box. So if the user selects radio button 1
or 2 from the frame, then either one of these will appear in Param1 *Received
from IDEM* or *Submitted to IDEM*, if the user select option 3, then in Param
1 is *Received from IDEM* and Param2 is *Submitted to IDEM*. When the user
clicks the run query button, the query runs, it looks at both text boxes but
if one is null it does not return a result. I think this would only work for
three or less options though.
--
Never give up, the answer IS out there, it just takes a while to find it
sometimes!


Douglas J Steele said:
Unfortunately, that won't work.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Larry G. said:
LOL - OK thanks! I am taking a different approach anyway now - I think I am
going to try for the parameter in the query "Like
[Forms]![MyForm]![txtParameter], and have the value of the parameter read
"*Parameter1*" OR "Parameter2"

--
Never give up, the answer IS out there, it just takes a while to find it
sometimes!


Douglas J Steele said:
That's what I'm trying to say: I don't understand what Dev meant when he
said you could. I can't think of how you'd do it...

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Right, I got that too. My question is: How do I create the query then to
USE
what is in that text box, where do I put the
"[Forms]![frmMyForm]![txtTextBox] reference?
--
Never give up, the answer IS out there, it just takes a while to find it
sometimes!


:

Whether or not a control is hidden doesn't change how you refer to it.

However, having said that, I'm not quite sure what Dev had in mind when
he
said you could manually assign the complete WHERE clause to a hidden
control.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Thanks for the info - it does the trick!

My other problem then is how do I get the query to reference what is
in
the
invisble text box? Since it is a complete SQL statement?
--
Never give up, the answer IS out there, it just takes a while to find
it
sometimes!


:

Since the AfterUpdate event will occur with each selection, you're
best
off
having a button for the user to click on when they've finished
making
selections, and put the code in that button's Click event.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Would this code go into the AfterUpdate event or somewhere else?
--
Never give up, the answer IS out there, it just takes a while to
find
it
sometimes!


:

Combo boxes do not allow more than one selection. End of
discussion.

Only List boxes allow you to make more than one selection (and
not
by
default: you have to set the control's MultiSelect property to
either
Simple
or Extended).

If by "how do I use the ItemSelected property in the query?" you
mean is
there some way for a query to refer to a list box set for
MultiSelect
and
use what's selected as its criteria, the answer is no, at least,
not
directly.

http://www.mvps.org/access/forms/frm0007.htm at "The Access Web"
shows
one
way how you can alter the SQL associated with a query to accept
multiselected items from a list box, although to be honest, I
prefer:

Dim frm As Form, ctl As Control
Dim varItem As Variant
Dim strSQL As String

Set frm = Form!frmMyForm
Set ctl = frm!lbMultiSelectListbox

If ctl.ItemsSelected.Count > 0 Then
strSQL = "Select * from Employees where [EmpID] IN ("
For Each varItem In ctl.ItemsSelected
strSQL = strSQL & ctl.ItemData(varItem) & ", "
Next varItem

strSQL=Left$(strSQL,Len(strSQL)-2)) & ")"
End If




--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Well I guess now the question is how do I use the ItemSelected
property in
the query?
--
Never give up, the answer IS out there, it just takes a while
to
find
it
sometimes!


:

Is there a way to make a Combo Box accept multiple
selections?

I have a table that has look-up values for two fields, and I
want
users
to
be able to print a report with more than one of these
options.

If anyone has any suggestions about how to do this I would
appreciate
it.
--
Never give up, the answer IS out there, it just takes a
while to
find it
sometimes!
 
D

Douglas J Steele

Yes, that would work.

You could use

LIKE Nz(Forms![MyForm]![MyControl], "*")

or

LIKE Forms![MyForm]![MyControl] OR (Forms![MyForm]![MyControl] IS NULL)

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Larry G. said:
I may not have explained it correctly, but it does work the way I envisioned
it. I had to add a second invisible text box, named txtParam2, and then added
an OR line in the query to look at what is in there, if it is null, it only
returns what is in the txtParam1 box. So if the user selects radio button 1
or 2 from the frame, then either one of these will appear in Param1 *Received
from IDEM* or *Submitted to IDEM*, if the user select option 3, then in Param
1 is *Received from IDEM* and Param2 is *Submitted to IDEM*. When the user
clicks the run query button, the query runs, it looks at both text boxes but
if one is null it does not return a result. I think this would only work for
three or less options though.
--
Never give up, the answer IS out there, it just takes a while to find it
sometimes!


Douglas J Steele said:
Unfortunately, that won't work.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Larry G. said:
LOL - OK thanks! I am taking a different approach anyway now - I think
I
am
going to try for the parameter in the query "Like
[Forms]![MyForm]![txtParameter], and have the value of the parameter read
"*Parameter1*" OR "Parameter2"

--
Never give up, the answer IS out there, it just takes a while to find it
sometimes!


:

That's what I'm trying to say: I don't understand what Dev meant when he
said you could. I can't think of how you'd do it...

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Right, I got that too. My question is: How do I create the query
then
to
USE
what is in that text box, where do I put the
"[Forms]![frmMyForm]![txtTextBox] reference?
find
it
sometimes!


:

Whether or not a control is hidden doesn't change how you refer
to
it.
However, having said that, I'm not quite sure what Dev had in
mind
when
he
said you could manually assign the complete WHERE clause to a hidden
control.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Thanks for the info - it does the trick!

My other problem then is how do I get the query to reference
what
is
in
the
invisble text box? Since it is a complete SQL statement?
to
find
it
sometimes!


:

Since the AfterUpdate event will occur with each selection, you're
best
off
having a button for the user to click on when they've finished
making
selections, and put the code in that button's Click event.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Would this code go into the AfterUpdate event or somewhere else?
while
to
find
it
sometimes!


:

Combo boxes do not allow more than one selection. End of
discussion.

Only List boxes allow you to make more than one
selection
(and
not
by
default: you have to set the control's MultiSelect
property
to
either
Simple
or Extended).

If by "how do I use the ItemSelected property in the
query?"
you
mean is
there some way for a query to refer to a list box set for
MultiSelect
and
use what's selected as its criteria, the answer is no,
at
least,
Access
Web"
shows
one
way how you can alter the SQL associated with a query to accept
multiselected items from a list box, although to be
honest,
I
prefer:

Dim frm As Form, ctl As Control
Dim varItem As Variant
Dim strSQL As String

Set frm = Form!frmMyForm
Set ctl = frm!lbMultiSelectListbox

If ctl.ItemsSelected.Count > 0 Then
strSQL = "Select * from Employees where [EmpID] IN ("
For Each varItem In ctl.ItemsSelected
strSQL = strSQL & ctl.ItemData(varItem) & ", "
Next varItem

strSQL=Left$(strSQL,Len(strSQL)-2)) & ")"
End If




--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Well I guess now the question is how do I use the ItemSelected
property in
the query?
a
while
to
find
it
sometimes!


:

Is there a way to make a Combo Box accept multiple
selections?

I have a table that has look-up values for two
fields,
and I
want
users
to
be able to print a report with more than one of these
options.

If anyone has any suggestions about how to do this I would
appreciate
it.
--
Never give up, the answer IS out there, it just takes a
while to
find it
sometimes!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top