SiHodgy007
asked on
VBA Vbscript Issue
Hi,
I'm trying to add a 'String' to the end of a SQL statement assigned a variable called SQL but it fails because of the parenthesis.
SQL = SQL & "'String'"
Any ideas?
I'm trying to add a 'String' to the end of a SQL statement assigned a variable called SQL but it fails because of the parenthesis.
SQL = SQL & "'String'"
Any ideas?
ASKER
That works, no idea how.
Is there a way now to replace the string with a variable that contains a string?
Is there a way now to replace the string with a variable that contains a string?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Awesome can you just explain the logic of the statement?
if last char is ) then replace the ) with 'string' ) else add 'string' at the end of text
ASKER
Sorry just trying to get the logic in my head, if I knew there wasn't a ) what would the code look like?
ASKER
sql = sql & " '" & String& "'"
That's right
but corrected code for the other possibility
but corrected code for the other possibility
strString = "String"
sql = IIf(Right(sql, 1) = ")", Left(sql, Len(sql) - 1) & " '" & strString & "')", sql & " '" & strString & "'")
ASKER
Thanks
pls try
Open in new window
Regards