尝试打印快速报告时出现EOleException错误

时间:2018-07-02 23:13:10

标签: ms-access-2010 delphi-7

我有一个名为var paramsTarget = { Ids: [ /* required */ `Target_ForOrder_${order_id}` /* more items */ ], Rule: `ForOrder_${order_id}` /* required */ }; cloudwatchevents.removeTargets(paramsTarget, function(err, data) { if (err) { console.log(err, err.stack) } else { console.log(data); var params = { Name: `ForOrder_${order_id}` }; cloudwatchevents.deleteRule(params, function(err, data) { if (err) { console.log(err, err.stack); } else { console.log("Delete cloudwatch rule successful! - data: " + JSON.stringify(data, null, 2)); } callback(null, result); }); } }); 的Access数据库表,具有以下字段名称:Receipts receipt numberitem namebuying price。我正在使用Adoquery和数据源连接到Access数据库。以下是我用于打印报告的代码。

selling price

但是,当我运行该程序然后在运行时单击procedure TReceiptsform.BitBtn1Click(Sender: TObject); var qry :string; begin with ADOQuery1 do begin if ADOQuery1.Locate('receipt number',Edit1.Text,[]) then open; SQL.Clear; qry:= 'SELECT*from Receipts WHERE (((Receipts.[receipt number])='+ edit1.Text+'))order by Receipts.[Item name]'; SQL.Add(qry); Active:= True; ReceiptForm.QuickRep1.Preview; end; end; 时,会出现此错误。

BitBtn1Click

我可以使用哪些异常处理代码来防止出现此错误,或者查询是否存在问题?

1 个答案:

答案 0 :(得分:0)

您的问题是,如果Edit1为 Null ,则由于使用+消除了引号,因此没有任何值可以过滤:

'SELECT * from Receipts WHERE (((Receipts.[receipt number])='+ edit1.Text+'))order by Receipts.[Item name]'

=>

'SELECT * from Receipts WHERE (((Receipts.[receipt number])=)) order by Receipts.[Item name]'

因此,请使用和号和一些空格:

'SELECT * from Receipts WHERE (((Receipts.[receipt number])=' & edit1.Text &')) order by Receipts.[Item name]'