Re: SQL String variable within another String Variable
- From: RoyVidar <roy_vidarNOSPAM@xxxxxxxx>
- Date: Sat, 17 Feb 2007 23:45:16 +0100
"Steve S" <SteveS@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
<8994D928-0E32-43C2-90D1-6E9C15D2F6A8@xxxxxxxxxxxxx>:
How do I code the following
strInput = "a test"
MsgBox (strInput)
strSQL = "INSERT INTO Comments (Comment) SELECT " & strInput & "as
X;" MsgBox (strSQL)
DoCmd.RunSQL strSQL
so the variable - strInput - is resolved to produce this SQL
statement:
INSERT INTO Comments (Comment) SELECT " Steve " as X;
the last line works fine when I hard code the text I want. I just
can't get the variable tobe resolved correctly.
Steve
Text will need tex delimiters (single quotes), try
strSQL = "INSERT INTO Comments (Comment) Values ('" & _
strInput & "')"
If there's a possibility that the text could contain single quotes, or
other special characters, you might try "doublequoting"
strSQL = "INSERT INTO Comments (Comment) Values (""" & _
strInput & """)"
--
Roy-Vidar
.
- Prev by Date: RE: Generating SQL w/2 "WHERE" Arguments from cbo
- Next by Date: Re: Hiding A Field
- Previous by thread: Hiding A Field
- Next by thread: Re: Combo doesn't allow selection
- Index(es):
Relevant Pages
|