This is a multi-part message in MIME format.

------=_NextPart_000_005D_01C4B74E.88CF5E00
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

Good Morning,

Got some good advice yesterday, but still running into issues. I am =
trying to query an Access db once a user selects a month/yr from a =
dropdown list. =20

Below is summary of my code:
=20
Dim CurrentStrMth as String=20
Dim CurrentEndMth as String

if drpdate.selecteditem.text =3D "JANUARY 04" then=20
CurrentStrMth =3D "#1/1/2004#"=20
CurrentEndMth =3D "#1/31/2004#" =20

When I run the query below without passing any variables it works fine:
cmdSelect1 =3D New OleDbCommand("SELECT Count(*) from db WHERE [Submit =
Date/Time]>=3D#1/1/2004# and [Submit =
Date/Time]<=3D#1/31/2004#",dbconnection)

However, when I try to incorporate the string variables, as noted below, =
into the query I get "Character constant must contain exactly one =
character". I can't find anything on this on the web!=20

cmdSelect1 =3D New OleDbCommand("Select Count(*) from db where [submit =
date/time] >=3D '"CurrentStrMth"' and [submit date/time] <=3D =
'"CurrentEndMth"'", dbconnection)

If someone could assist me further with this issue, it would be greatly =
appreciated?

Thanks in advance!
MKC
------=_NextPart_000_005D_01C4B74E.88CF5E00
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Diso-8859-1">
<META content=3D"MSHTML 6.00.2800.1476" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2>Good Morning,</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Got some good advice yesterday, but =
still running=20
into issues.&nbsp; I am trying to query an Access db once a user selects =
a=20
month/yr from a dropdown list.&nbsp;&nbsp;</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Below is summary of my =
code:</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV>Dim CurrentStrMth as String </DIV>
<DIV>Dim CurrentEndMth as String</DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV>if drpdate.selecteditem.text =3D "JANUARY 04" then </DIV>
<DIV>CurrentStrMth =3D "#1/1/2004#" </DIV>
<DIV>CurrentEndMth =3D "#1/31/2004#"&nbsp;&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>
<DIV><FONT face=3DArial size=3D2>When I run the&nbsp;query below without =
passing any=20
variables it works fine:</FONT></DIV>
<DIV>
<DIV>cmdSelect1 =3D New OleDbCommand("SELECT Count(*) from db WHERE =
[Submit=20
Date/Time]&gt;=3D#1/1/2004# and [Submit=20
Date/Time]&lt;=3D#1/31/2004#",dbconnection)</DIV></DIV></FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>However, when I try to incorporate the =
string=20
variables, as noted below, into the query I get "Character constant must =
contain=20
exactly one character".&nbsp; I can't&nbsp;find anything on this on the=20
web!&nbsp;</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV>cmdSelect1 =3D New OleDbCommand("Select Count(*) from db where =
[submit=20
date/time] &gt;=3D '"CurrentStrMth"' and [submit date/time] &lt;=3D=20
'"CurrentEndMth"'", dbconnection)</DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV>
<DIV><FONT face=3DArial size=3D2>If someone could&nbsp;assist me further =
with this=20
issue, it would be greatly appreciated?</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Thanks in advance!</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>MKC</FONT></DIV></DIV></BODY></HTML>

------=_NextPart_000_005D_01C4B74E.88CF5E00--

Re: Access Query Problem by W

W
Thu Oct 21 13:01:45 CDT 2004

This is a multi-part message in MIME format.

------=_NextPart_000_0015_01C4B776.7FF73D70
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

I think your commandtext is using the literal CurrentStrMth and =
CurrentEndMth isn't it? If I'm reading this right there's no =
concatenation so those literals are in there. I'd recommend using =
Parameters anyway:

("Select Count(*) from db where [submit date/time] >=3D ? and [submit =
date/time] <=3D?", dbconnection)
cmdSelect1.Parameters.Add(CurrentStrMth);
cmdSelect1.Parameters.Add(CurrentEndMth);

HTH,

Bill

--=20
W.G. Ryan, MVP

www.tibasolutions.com | www.devbuzz.com | www.knowdotnet.com
"Keith" <kcomp1@hotmail.com> wrote in message =
news:OcvL1h3tEHA.224@TK2MSFTNGP15.phx.gbl...
Good Morning,

Got some good advice yesterday, but still running into issues. I am =
trying to query an Access db once a user selects a month/yr from a =
dropdown list. =20

Below is summary of my code:

Dim CurrentStrMth as String=20
Dim CurrentEndMth as String

if drpdate.selecteditem.text =3D "JANUARY 04" then=20
CurrentStrMth =3D "#1/1/2004#"=20
CurrentEndMth =3D "#1/31/2004#" =20

When I run the query below without passing any variables it works =
fine:
cmdSelect1 =3D New OleDbCommand("SELECT Count(*) from db WHERE [Submit =
Date/Time]>=3D#1/1/2004# and [Submit =
Date/Time]<=3D#1/31/2004#",dbconnection)

However, when I try to incorporate the string variables, as noted =
below, into the query I get "Character constant must contain exactly one =
character". I can't find anything on this on the web!=20

cmdSelect1 =3D New OleDbCommand("Select Count(*) from db where [submit =
date/time] >=3D '"CurrentStrMth"' and [submit date/time] <=3D =
'"CurrentEndMth"'", dbconnection)

If someone could assist me further with this issue, it would be =
greatly appreciated?

Thanks in advance!
MKC
------=_NextPart_000_0015_01C4B776.7FF73D70
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Diso-8859-1">
<META content=3D"MSHTML 6.00.2800.1476" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2>I think your commandtext is using the =
literal=20
CurrentStrMth and CurrentEndMth isn't it?&nbsp; If I'm reading this =
right=20
there's no concatenation so those literals are in there.&nbsp; I'd =
recommend=20
using Parameters anyway:</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV>("Select Count(*) from db where [submit date/time] &gt;=3D&nbsp;? =
and [submit=20
date/time] &lt;=3D?", dbconnection)</DIV>
<DIV>cmdSelect1.Parameters.Add(CurrentStrMth);</DIV>
<DIV>cmdSelect1.Parameters.Add(CurrentEndMth);</DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>HTH,</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Bill</FONT></DIV>
<DIV><BR>-- <BR>W.G. Ryan, MVP</DIV>
<DIV>&nbsp;</DIV>
<DIV><A href=3D"http://www.tibasolutions.com">www.tibasolutions.com</A> =
| <A=20
href=3D"http://www.devbuzz.com">www.devbuzz.com</A> | <A=20
href=3D"http://www.knowdotnet.com">www.knowdotnet.com</A></DIV>
<BLOCKQUOTE dir=3Dltr=20
style=3D"PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; =
BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
<DIV>"Keith" &lt;<A=20
href=3D"mailto:kcomp1@hotmail.com">kcomp1@hotmail.com</A>&gt; wrote in =
message=20
<A=20
=
href=3D"news:OcvL1h3tEHA.224@TK2MSFTNGP15.phx.gbl">news:OcvL1h3tEHA.224@T=
K2MSFTNGP15.phx.gbl</A>...</DIV>
<DIV><FONT face=3DArial size=3D2>Good Morning,</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Got some good advice yesterday, but =
still running=20
into issues.&nbsp; I am trying to query an Access db once a user =
selects a=20
month/yr from a dropdown list.&nbsp;&nbsp;</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Below is summary of my =
code:</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV>Dim CurrentStrMth as String </DIV>
<DIV>Dim CurrentEndMth as String</DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV>if drpdate.selecteditem.text =3D "JANUARY 04" then </DIV>
<DIV>CurrentStrMth =3D "#1/1/2004#" </DIV>
<DIV>CurrentEndMth =3D "#1/31/2004#"&nbsp;&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>
<DIV><FONT face=3DArial size=3D2>When I run the&nbsp;query below =
without passing=20
any variables it works fine:</FONT></DIV>
<DIV>
<DIV>cmdSelect1 =3D New OleDbCommand("SELECT Count(*) from db WHERE =
[Submit=20
Date/Time]&gt;=3D#1/1/2004# and [Submit=20
Date/Time]&lt;=3D#1/31/2004#",dbconnection)</DIV></DIV></FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>However, when I try to incorporate =
the string=20
variables, as noted below, into the query I get "Character constant =
must=20
contain exactly one character".&nbsp; I can't&nbsp;find anything on =
this on=20
the web!&nbsp;</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV>cmdSelect1 =3D New OleDbCommand("Select Count(*) from db where =
[submit=20
date/time] &gt;=3D '"CurrentStrMth"' and [submit date/time] &lt;=3D=20
'"CurrentEndMth"'", dbconnection)</DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV>
<DIV><FONT face=3DArial size=3D2>If someone could&nbsp;assist me =
further with this=20
issue, it would be greatly appreciated?</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Thanks in advance!</FONT></DIV>
<DIV><FONT face=3DArial =
size=3D2>MKC</FONT></DIV></DIV></BLOCKQUOTE></BODY></HTML>

------=_NextPart_000_0015_01C4B776.7FF73D70--