Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/vb.net/17.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
&引用;“未给出任何值”;sql的where子句中出错_Sql_Vba - Fatal编程技术网

&引用;“未给出任何值”;sql的where子句中出错

&引用;“未给出任何值”;sql的where子句中出错,sql,vba,Sql,Vba,具有以下代码: Dim MasterIDIn As Double 'Use in where clause MasterIDIn = CDbl(Me!scanTxtBox.Value) Dim RCMSql As String RCMSql = "SELECT [Range Card Master Mailer].Master_ID," & _ "[Range Card Master Mailer].MaxOfDate_of_Tr

具有以下代码:

    Dim MasterIDIn As Double         'Use in where clause
    MasterIDIn = CDbl(Me!scanTxtBox.Value)

    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)= MasterIDIn))"
     RCMRs.Open RCMSql                       'Fill the recordset
open抛出错误

“一个或多个参数没有给定值”

如果我删除where子句,它将运行。文件上的Master_ID字段是double,因此我将textbox值转换为double,看起来应该可以工作。在即时窗口中,MasterIDin和CDbl(Me!scanTxtBox.Value)具有相同的值。 我一定错过了什么


谢谢

您需要动态创建字符串,以允许
MasterIDIn
在VBA代码中获取其值。目前,您实际上正在寻找
MasterID
“MasterIDIn”

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)= " & MasterIDIn & "))"
     RCMRs.Open RCMSql                       'Fill the recordset

我猜
MasterIDIn
应该是一个值,而不是在字符串中传递。这似乎正确吗?[Range Card Master Mailer].Master_ID=MasterId收到了,非常感谢