[英]Replace in SQL in VBA
替換仍然有問題。 使用以下sql:
Dim UpDtFlag As String
UpDtFlag = "UPDATE [Range Card Master Mailer] SET [Range Card Master Mailer].RedeemDate = Now(), [Range Card Master Mailer].RedeemFlag = 'Y' " & _
"WHERE ((([Range Card Master Mailer].Master_ID) = '" & _
Replace(Me!scanTxtBox, "'", "''") & "'))"
DoCmd.RunSQL UpDtFlag
問題出在Me!scanTxtBox中。 獲得幫助並在以下方面成功使用它:
Dim RCMSql As String
RCMSql = "SELECT [Range Card Master Mailer].Master_ID," & _
"[Range Card Master Mailer].MaxOfDate_of_Transaction," & _
"[Range Card Master Mailer].FirstName," & _
"[Range Card Master Mailer].LastName," & _
"[Range Card Master Mailer].Email_Address," & _
"[Range Card Master Mailer].Address_Line_1," & _
"[Range Card Master Mailer].Phone_Number_1," & _
"[Range Card Master Mailer].Phone_Number_2," & _
"[Range Card Master Mailer].Date_Sent," & _
"[Range Card Master Mailer].CouponValue," & _
"[Range Card Master Mailer].RedeemDate," & _
"[Range Card Master Mailer].RedeemFlag " & _
"FROM [Range Card Master Mailer] " & _
"WHERE ((([Range Card Master Mailer].Master_ID) = '" & _
Replace(Me!scanTxtBox, "'", "''") & "'))"
RCMRs.Open RCMSql
試圖將替換項復制到問題查詢中,但問題查詢顯然不了解標點符號或其他內容。 還嘗試使用像BalanceStr =“'”&scanTxtBox&“'”之類的串聯,然后在sql中使用Balancestr。 沒工作
謝謝
jpl
我用以下命令運行它:
Dim UpDtFlag As String
UpDtFlag = "UPDATE [Range Card Master Mailer] SET [Range Card Master Mailer].RedeemDate = Now(), [Range Card Master Mailer].RedeemFlag = 'Y' " & _
"WHERE ((([Range Card Master Mailer].Master_ID) = '" & _
Replace(Me!scanTxtBox, "'", "''") & "'))"
DoCmd.RunSQL UpDtFlag 'Reset after testing of printer
謝謝
jpl
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.