G
Guest
I'm trying to pass a variable to a SQL query and am not having success. I'm
calling the function from a macro with RUNCODE.
Note that when I replace the variable "concatquoteheader" with the number 2
in the SQL statement, it runs correctly. When I use the variable, a message
appears asking me to input text for "concatquoteheader" (much like a
parameter). Also, if I set concatquoteheader variable = "test", it also
fails.
One other note ... the control "quoteheader" is a text box on a form and the
field tblSalesJobMastQuotes.quoteheader is type memo.
Here's the module:
Option Compare Database
++++++++++++++
Public Sub ConcatenateHeader()
Dim concatquoteheader As String
Dim header1 As String
Dim header2 As String
header1 = Mid(Forms![frmSalesJob]![quoteheader], 1, 250)
header2 = Mid(Forms![frmSalesJob]![quoteheader], 251, 250)
concatquoteheader = header1 & header2
DoCmd.RunSQL "UPDATE tblSalesJobMastQuotes SET
tblSalesJobMastQuotes.quoteheader = concatquoteheader WHERE
(((tblSalesJobMastQuotes.documentnumber)=[Forms]![frmSalesJob]![salesnumber]
& [Forms]![frmSalesJob]![documentversion]))"
End Sub
++++++++++++++
Public Function callconcatquote()
Call ConcatenateHeader
End Function
++++++++++++++
Any help is greatly appreciated. Thanks in advance.
Gary
calling the function from a macro with RUNCODE.
Note that when I replace the variable "concatquoteheader" with the number 2
in the SQL statement, it runs correctly. When I use the variable, a message
appears asking me to input text for "concatquoteheader" (much like a
parameter). Also, if I set concatquoteheader variable = "test", it also
fails.
One other note ... the control "quoteheader" is a text box on a form and the
field tblSalesJobMastQuotes.quoteheader is type memo.
Here's the module:
Option Compare Database
++++++++++++++
Public Sub ConcatenateHeader()
Dim concatquoteheader As String
Dim header1 As String
Dim header2 As String
header1 = Mid(Forms![frmSalesJob]![quoteheader], 1, 250)
header2 = Mid(Forms![frmSalesJob]![quoteheader], 251, 250)
concatquoteheader = header1 & header2
DoCmd.RunSQL "UPDATE tblSalesJobMastQuotes SET
tblSalesJobMastQuotes.quoteheader = concatquoteheader WHERE
(((tblSalesJobMastQuotes.documentnumber)=[Forms]![frmSalesJob]![salesnumber]
& [Forms]![frmSalesJob]![documentversion]))"
End Sub
++++++++++++++
Public Function callconcatquote()
Call ConcatenateHeader
End Function
++++++++++++++
Any help is greatly appreciated. Thanks in advance.
Gary