where statement, text string & wild card

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I wish to pass a where statement to open a report.
I currently have

Dim strInput As String

strInput = "[Company Query]!PostalCode = '" & Me.txtadd & "'"
DoCmd.OpenReport "Company Report", acViewPreview, , strInput

this works fine.

however i wish to adjust this code to use the where statement to search for
anything begning with Me.txtadd

i gather that i need to use LIKE instead of equals and put * in at the end.
however all the commas are causing me problems

any advice??
 
Brilliant
--
thanks
liz


Lynn Trapp said:
Try something like this:

Dim strInput As String

strInput = "[Company Query]!PostalCode LIKE '" & Me.txtadd & "*" & "'"

WARNING: Untested "Air" Code


--
Lynn Trapp
MS Access MVP
www.ltcomputerdesigns.com
Access Security: www.ltcomputerdesigns.com/Security.htm
Jeff Conrad's Access Junkie List:
http://home.bendbroadband.com/conradsystems/accessjunkie.html



liz said:
I wish to pass a where statement to open a report.
I currently have

Dim strInput As String

strInput = "[Company Query]!PostalCode = '" & Me.txtadd & "'"
DoCmd.OpenReport "Company Report", acViewPreview, , strInput

this works fine.

however i wish to adjust this code to use the where statement to search
for
anything begning with Me.txtadd

i gather that i need to use LIKE instead of equals and put * in at the
end.
however all the commas are causing me problems

any advice??
 
I'm glad it helped.

--
Lynn Trapp
MS Access MVP
www.ltcomputerdesigns.com
Access Security: www.ltcomputerdesigns.com/Security.htm
Jeff Conrad's Access Junkie List:
http://home.bendbroadband.com/conradsystems/accessjunkie.html



liz said:
Brilliant
--
thanks
liz


Lynn Trapp said:
Try something like this:

Dim strInput As String

strInput = "[Company Query]!PostalCode LIKE '" & Me.txtadd & "*" & "'"

WARNING: Untested "Air" Code


--
Lynn Trapp
MS Access MVP
www.ltcomputerdesigns.com
Access Security: www.ltcomputerdesigns.com/Security.htm
Jeff Conrad's Access Junkie List:
http://home.bendbroadband.com/conradsystems/accessjunkie.html



liz said:
I wish to pass a where statement to open a report.
I currently have

Dim strInput As String

strInput = "[Company Query]!PostalCode = '" & Me.txtadd & "'"
DoCmd.OpenReport "Company Report", acViewPreview, , strInput

this works fine.

however i wish to adjust this code to use the where statement to search
for
anything begning with Me.txtadd

i gather that i need to use LIKE instead of equals and put * in at the
end.
however all the commas are causing me problems

any advice??
 
Another question along similar lines....

strInput = "[Company Query]!Casino = True'"

The data type stored in the casino field is a yes/no tick box.
I want it to match the ones that have been tickes (so the Yes/True/On) but
am not sure how to code this!?

--
thanks
liz


Lynn Trapp said:
I'm glad it helped.

--
Lynn Trapp
MS Access MVP
www.ltcomputerdesigns.com
Access Security: www.ltcomputerdesigns.com/Security.htm
Jeff Conrad's Access Junkie List:
http://home.bendbroadband.com/conradsystems/accessjunkie.html



liz said:
Brilliant
--
thanks
liz


Lynn Trapp said:
Try something like this:

Dim strInput As String

strInput = "[Company Query]!PostalCode LIKE '" & Me.txtadd & "*" & "'"

WARNING: Untested "Air" Code


--
Lynn Trapp
MS Access MVP
www.ltcomputerdesigns.com
Access Security: www.ltcomputerdesigns.com/Security.htm
Jeff Conrad's Access Junkie List:
http://home.bendbroadband.com/conradsystems/accessjunkie.html



I wish to pass a where statement to open a report.
I currently have

Dim strInput As String

strInput = "[Company Query]!PostalCode = '" & Me.txtadd & "'"
DoCmd.OpenReport "Company Report", acViewPreview, , strInput

this works fine.

however i wish to adjust this code to use the where statement to search
for
anything begning with Me.txtadd

i gather that i need to use LIKE instead of equals and put * in at the
end.
however all the commas are causing me problems

any advice??
 
You have an unnecessary single quote in there, after the word True.


--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


liz said:
Another question along similar lines....

strInput = "[Company Query]!Casino = True'"

The data type stored in the casino field is a yes/no tick box.
I want it to match the ones that have been tickes (so the Yes/True/On) but
am not sure how to code this!?

--
thanks
liz


Lynn Trapp said:
I'm glad it helped.

--
Lynn Trapp
MS Access MVP
www.ltcomputerdesigns.com
Access Security: www.ltcomputerdesigns.com/Security.htm
Jeff Conrad's Access Junkie List:
http://home.bendbroadband.com/conradsystems/accessjunkie.html



liz said:
Brilliant
--
thanks
liz


:

Try something like this:

Dim strInput As String

strInput = "[Company Query]!PostalCode LIKE '" & Me.txtadd & "*" & "'"

WARNING: Untested "Air" Code


--
Lynn Trapp
MS Access MVP
www.ltcomputerdesigns.com
Access Security: www.ltcomputerdesigns.com/Security.htm
Jeff Conrad's Access Junkie List:
http://home.bendbroadband.com/conradsystems/accessjunkie.html



I wish to pass a where statement to open a report.
I currently have

Dim strInput As String

strInput = "[Company Query]!PostalCode = '" & Me.txtadd & "'"
DoCmd.OpenReport "Company Report", acViewPreview, , strInput

this works fine.

however i wish to adjust this code to use the where statement to search
for
anything begning with Me.txtadd

i gather that i need to use LIKE instead of equals and put * in at the
end.
however all the commas are causing me problems

any advice??
 
Atleast it was an easy problem!!!
--
thanks very much
liz


Douglas J Steele said:
You have an unnecessary single quote in there, after the word True.


--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


liz said:
Another question along similar lines....

strInput = "[Company Query]!Casino = True'"

The data type stored in the casino field is a yes/no tick box.
I want it to match the ones that have been tickes (so the Yes/True/On) but
am not sure how to code this!?

--
thanks
liz


Lynn Trapp said:
I'm glad it helped.

--
Lynn Trapp
MS Access MVP
www.ltcomputerdesigns.com
Access Security: www.ltcomputerdesigns.com/Security.htm
Jeff Conrad's Access Junkie List:
http://home.bendbroadband.com/conradsystems/accessjunkie.html



Brilliant
--
thanks
liz


:

Try something like this:

Dim strInput As String

strInput = "[Company Query]!PostalCode LIKE '" & Me.txtadd & "*" & "'"

WARNING: Untested "Air" Code


--
Lynn Trapp
MS Access MVP
www.ltcomputerdesigns.com
Access Security: www.ltcomputerdesigns.com/Security.htm
Jeff Conrad's Access Junkie List:
http://home.bendbroadband.com/conradsystems/accessjunkie.html



I wish to pass a where statement to open a report.
I currently have

Dim strInput As String

strInput = "[Company Query]!PostalCode = '" & Me.txtadd & "'"
DoCmd.OpenReport "Company Report", acViewPreview, , strInput

this works fine.

however i wish to adjust this code to use the where statement to search
for
anything begning with Me.txtadd

i gather that i need to use LIKE instead of equals and put * in at the
end.
however all the commas are causing me problems

any advice??
 

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

Back
Top