Dates and Variables

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

Guest

I'm trying to hit a stored procedure in SQL but I'm getting an error when I'm
passing anything that needs the quotes " " for SQL.

How do I pass the quotes in a variable?

I'm sure it's amazingly simple but I'm lost.
objCmd(1) = "10/25/2000"
 
did you try the double quote

objCmd(1) = ""10/25/2000""
or objCmd(1) = """&10/25/2000&"""
 
Hi Michael,

I believe you'll find that the previously supplied example is short a
quotation mark, Try this example:


Sub QuoteMe()
Dim strParameter As String

strParameter = "10/25/2000"

MsgBox """" & strParameter & """"

End Sub



Note that the parameter value is surrounded by 4 (four) quote marks.

Good Coding

OfficeHacker
Melbourne, Australia
 
Michael$Lost said:
I'm trying to hit a stored procedure in SQL but I'm getting an error when I'm
passing anything that needs the quotes " " for SQL.

How do I pass the quotes in a variable?

I'm sure it's amazingly simple but I'm lost.
objCmd(1) = "10/25/2000"

Instead of double quotes Chr$(34), try single quotes Chr$(39), which is
ANSI standard syntax. BTW if your column is a temporal data type (e.g.
DATETIME), try using an unambiguous date format e.g.

objCmd(1) = Chr$(39) & "2000-10-25" & Chr$(39)

Note your product may have a different 'date delimiter' e.g. MS Access
uses the hash character Chr$(39).

Jamie.

--
 

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