Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Quotes in SQL statments

Status
Not open for further replies.

ferryjenny

Technical User
Nov 22, 2000
24
GB
Hi

I am trying to write an SQL statment that uses a DSum function however it seems to be having trouble interpreting the quotes I am using the SQL is

"SELECT Message.Time, Message.Amount, Message.[Free Text] AS Sender, "&_
&quot;DSum('[Amount]','[Message]','[Time]<= #' & DateAdd('h',-2,[Time]) & '# And [Type ID] = 'cp'') AS Population &quot;&_
&quot;FROM Message &quot;&_
&quot;WHERE [Message]![Type ID]='cp'&quot;

I think the problem is caused because I have 2 single quotes at the end of the DSum line but I have tried double quotes and they dont work

Any help would be very much appreciated
 
&quot;SELECT Message.Time, Message.Amount, Message.[Free Text] AS Sender, DSum('[Amount]','[Message]','[Time]<= #' & DateAdd('h',-2,[Time]) & '# And [Type ID] = 'cp'') AS Population FROM Message WHERE [Message]![Type ID]='cp'&quot;


That is what your SQL stmt looks like all together.
Make sure there isn't a problem with parenthesis or commas either.

Where it says [Type ID]... it will insert something that looks like:
cp'
Is that what you want? If not, remove one of the single quotes. -Phil
fillup07@hotmail.com
If my post was helpful, please give me a star!
 
I have the answer now thanks I needed to put another pair of single quotes around the first CP
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top