ADODB.Recordset:关闭对象时不允许操作

时间:2019-06-04 16:28:57

标签: vba ms-access adodb recordset

我正在尝试根据emp_name和当前日期更新特定字段中的列,即注销时间。 如果找不到当前日期和emp_name,则应显示味精。

我使用了Recordset.EOF,但它在这一行上给出了错误。

  Set Connection = New ADODB.Connection
  Connect = "Provider=Microsoft.ACE.OLEDB.12.0;"
  Connect = Connect & "Data Source=" & DBFullName & ";"
  Connection.Open ConnectionString:=Connect


  'Create RecordSet
  Set Recordset = New ADODB.Recordset
  With Recordset

'Filter Data
Dim emp_name As Variant
emp_name = Replace(Application.UserName, ",", "")
Source = "UPDATE timetbl Set logouttime =#" & tmp & "#  where empname =  '" & emp_name & "' and c_date=#" & Date & "#"
.Open Source:=Source, ActiveConnection:=Connection
If Recordset.EOF = False Then 'error is here
   MsgBox "Please Login first"
Else
    'My code is here
End If

0 个答案:

没有答案