Date Delimiter Problem

S

Scott

My code below is giving the syntax error when I try to pass a begin and end
date parameter to a sproc in my Access ADP Project. I've tried delimiting
the date parameters every way possible but continue to get a syntax error.
Can someone help with delimiting my dates?


' CODE *************

Dim sSQL As String

sSQL = "Exec [mySproc]" & " " & Forms!myForm!txtDateBegin & ", " &
Forms!myForm!txtDateEnd

Debug.Print sSQL
CurrentProject.Connection.Execute sSQL, , adExecuteNoRecords + adCmdText


' ERROR *************

Incorrect syntax near '/'
 
C

Clifford Bass

Hi Scott,

Try:

Dim cmd As New ADODB.Command

cmd.ActiveConnection = CurrentProject.Connection
cmd.CommandText = "mySproc"
cmd.Execute , Array(Forms!myForm!txtDateBegin, _
Forms!myForm!txtDateEnd), adCmdStoredProc

If necessary you could adjust the cmd.Execute line as follows:

cmd.Execute , Array(CDate(Forms!myForm!txtDateBegin), _
CDate(Forms!myForm!txtDateEnd)), adCmdStoredProc

Hope that helps,

Clifford Bass
 
M

Mike Painter

Scott said:
My code below is giving the syntax error when I try to pass a begin
and end date parameter to a sproc in my Access ADP Project. I've
tried delimiting the date parameters every way possible but continue
to get a syntax error. Can someone help with delimiting my dates?


' CODE *************

Dim sSQL As String

sSQL = "Exec [mySproc]" & " " & Forms!myForm!txtDateBegin & ", " &
Forms!myForm!txtDateEnd

Debug.Print sSQL
CurrentProject.Connection.Execute sSQL, , adExecuteNoRecords +
adCmdText

' ERROR *************

Incorrect syntax near '/'

& ", # " & Forms!myForm!txtDateEnd & "#"
 

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

Top