Combo box with "or" in code??

G

Guest

Hi,

I have a form with a combo box that filters another form based on type of
liquid selected. There are two fields that have liquids listed. Is there a
way to add an "or" statement to the following code to return all records that
have selected type of liquid in either field. I need to add the field
[FluidListedBySy].
Code currently used for one field filter is as follows:

Private Sub CboFluid_Click()

stLinkCriteria = "[Fluid] Like '*" & Me![CboLiquid] & "*'"
stDocName = "fCompiledList"

DoCmd.OpenForm stDocName, , , stLinkCriteria

End Sub

I've searched thru posts and can't seem to find exactly what I am wanting to
do.
As always, any help is greatly appreciated.
Thanks in advance,
Pam
 
D

Douglas J. Steele

stLinkCriteria = "[Fluid] Like '*" & Me![CboLiquid] & "*' Or [Fluid2] Like
'*" & Me![CboLiquid] & "*'"

(of course, fixing your table design so you don't have the two fields would
probably be better <g>)
 
G

Guest

Doug,
Thanks so much for the quick reply. It works just as I wanted. I know
having the two fields are not good in table design (and I knew someone was
going to tell me <g>), but I had two sets of info for one unit. I compiled
to make one record in a spreadsheet and then imported into Access. The two
lists don't always agree "exactly" on the fluid, so I left both. I thought
about having a subform for each table of info, but trying to code the filters
from the subforms was proving too difficult.

You always have such informative answers, do you have any ideas to share as
to make this more efficient?
Thanks again for the help!!
Pam

Douglas J. Steele said:
stLinkCriteria = "[Fluid] Like '*" & Me![CboLiquid] & "*' Or [Fluid2] Like
'*" & Me![CboLiquid] & "*'"

(of course, fixing your table design so you don't have the two fields would
probably be better <g>)

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


PHisaw said:
Hi,

I have a form with a combo box that filters another form based on type of
liquid selected. There are two fields that have liquids listed. Is there
a
way to add an "or" statement to the following code to return all records
that
have selected type of liquid in either field. I need to add the field
[FluidListedBySy].
Code currently used for one field filter is as follows:

Private Sub CboFluid_Click()

stLinkCriteria = "[Fluid] Like '*" & Me![CboLiquid] & "*'"
stDocName = "fCompiledList"

DoCmd.OpenForm stDocName, , , stLinkCriteria

End Sub

I've searched thru posts and can't seem to find exactly what I am wanting
to
do.
As always, any help is greatly appreciated.
Thanks in advance,
Pam
 
D

Douglas J. Steele

Sorry, without knowing more about your tables, I can't offer any specific
advice.

--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


PHisaw said:
Doug,
Thanks so much for the quick reply. It works just as I wanted. I know
having the two fields are not good in table design (and I knew someone was
going to tell me <g>), but I had two sets of info for one unit. I
compiled
to make one record in a spreadsheet and then imported into Access. The
two
lists don't always agree "exactly" on the fluid, so I left both. I
thought
about having a subform for each table of info, but trying to code the
filters
from the subforms was proving too difficult.

You always have such informative answers, do you have any ideas to share
as
to make this more efficient?
Thanks again for the help!!
Pam

Douglas J. Steele said:
stLinkCriteria = "[Fluid] Like '*" & Me![CboLiquid] & "*' Or [Fluid2]
Like
'*" & Me![CboLiquid] & "*'"

(of course, fixing your table design so you don't have the two fields
would
probably be better <g>)

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


PHisaw said:
Hi,

I have a form with a combo box that filters another form based on type
of
liquid selected. There are two fields that have liquids listed. Is
there
a
way to add an "or" statement to the following code to return all
records
that
have selected type of liquid in either field. I need to add the field
[FluidListedBySy].
Code currently used for one field filter is as follows:

Private Sub CboFluid_Click()

stLinkCriteria = "[Fluid] Like '*" & Me![CboLiquid] & "*'"
stDocName = "fCompiledList"

DoCmd.OpenForm stDocName, , , stLinkCriteria

End Sub

I've searched thru posts and can't seem to find exactly what I am
wanting
to
do.
As always, any help is greatly appreciated.
Thanks in advance,
Pam
 

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

Top