|
本帖最后由 真主 于 2019-1-31 12:17 编辑
方法一运行正常,方法二提示“Access运行时错误'3061':参数不足,期待是3”,请问错在哪里?
问题出现在Set Va_myrst = Va_mydb.OpenRecordset(Va_Str)
所以变量本来主字母缩写的,为了大家能看明白,所以改成了中文
方法一:
- Public Function VH_InTime(当日前日 As Integer, 可提前时间 As Date, 应上班时间 As Date, 可延后时间 As Date, 查询表名 As String, 查询表用户ID As String, 查询表刷卡日期 As String, 查询表刷卡时间 As String, 排班表人员ID As Integer, 排班表日期 As Date) As String
- If 当日前日 = 0 And 可提前时间 <= 应上班时间 <= 可延后时间 Then
- VH_InTime = DFirst(查询表刷卡时间, 查询表名, 查询表用户ID & "=" & 排班表人员ID & "and " & 查询表刷卡日期 & "=#" & 当日前日 + 排班表日期 & "#" & " and " & 查询表刷卡时间 & ">=#" & 可提前时间 & "#" & " and " & 查询表刷卡时间 & "<=#" & 可延后时间 & "#")
- End If
- End Function
复制代码
方法二:
- Public Function VH_InTime(当日前日 As Integer, 可提前时间 As Date, 应上班时间 As Date, 可延后时间 As Date, 查询表名 As String, 查询表用户ID As String, 查询表刷卡日期 As String, 查询表刷卡时间 As String, 排班表人员ID As Integer, 排班表日期 As Date) As Date '上班时间查找
- Dim Va_mydb As DAO.Database
- Dim Va_myrst As DAO.Recordset
- Dim Va_Str As String
- Set Va_mydb = CurrentDb
- If 当日前日 = 0 And 可提前时间 <= 应上班时间 <= 可延后时间 Then
- Va_Str = "Select " & 查询表刷卡时间 & " From " & 查询表名 & " Where " & 查询表用户ID & "=" & 排班表人员ID & " And " & 查询表刷卡日期 & "=#" & 当日前日 + 排班表日期 & "# and " & 查询表刷卡时间 & ">=#" & 可提前时间 & "# and " & 查询表刷卡时间 & "<=#" & 可延后时间 & "# Order By " & 查询表刷卡日期 & "," & 查询表刷卡时间
- End If
- Set Va_myrst = Va_mydb.OpenRecordset(Va_Str)
- VH_InTime = Va_myrst(0)
- End Function
复制代码
|
|