with CustomDriver do
try
with SelectCommand do
begin
CommandText.Text := 'select count(*) from OBJ_APP a' + ^M +
'where ID_App = :AID_App and exists (select 1 from obj_app b where b.ID_Obj = a.ID_Obj and b.ID_App = :AID_App_Replace)';
Parameters.ParamByName('AID_App').Value := AID_App;
Parameters.ParamByName('AID_App_Replace').Value := AID_App_Replace;
end;
vFree := True;
ExecuteCommand(SelectCommand, DsReplace, vFree);
if (DsReplace <> Nil)
and(DsReplace.RecordCount > 0)
and(DsReplace.Fields[0].AsInteger > 0) then
如何在VBA中编写最后三行代码?编写双引号比& Chr (34) &
有更简单的方法吗?
答案 0 :(得分:1)
打开记录集后,您只需要检查.EOF
。
Set rs = CurrentDb.OpenRecordset("SELECT * FROM foo")
If Not rs.EOF Then
If rs(0) > 0 Then
' or if you want to be explicit
If rs.Fields(0).Value > 0 Then
双引号被加倍掩盖:
Debug.Print "Hello ""World"""
但通常您可以使用单引号使代码更易读:
strSQL = "SELECT * FROM foo WHERE bar = 'something'"
答案 1 :(得分:0)
您还可以查看RecordCount
:
Set rs = CurrentDb.OpenRecordset("Select * From YourTable")
If rs.RecordCount > 0 Then
' At least one record exists.
' Do stuff.
End If
答案 2 :(得分:-3)
所有答案都错了。
错了,原因......
<强> 1。在记录计数之前,必须填充记录集!
2.强烈建议不要直接使用STROKE
CurrentDb