提醒的 MS 访问代码问题
MS Access Code issue for Reminders
我正在尝试根据从名为 "Tasks" 的 Table 添加的任务设置提醒这是我正在使用的代码,但有些地方不对,因为它一直给我带来问题以下行:
intStore = DCount("[TaskName]", "[Status]", "[DueDate] <=Now() AND [Complete] =0")
代码运行时出现错误:
Microsoft Access database engine cannot find the input table or query
for 'Status' Make sure it exists and is spelled correctly.
在我的 table 中,我有 任务名称、状态 和 截止日期 所以我不确定为什么会出现这种情况。
下面是整行代码:
Private Sub Form_Load()
'On Load of the switchboard check Jobs table for any uncompleted jobs
Dim intStore As Integer
intStore = DCount("[Priority]", "[Tasks]", "[DueDate] <=Now() AND [PercentComplete] <=0")
If intStore = 0 Then
Exit Sub
Else
If MsgBox("There are " & intStore & " uncompleted jobs" & _
vbCrLf & vbCrLf & "Would you like to see these now?", _
vbYesNo, "You Have Uncomplete Jobs...") = vbYes Then
DoCmd.Minimize
DoCmd.OpenForm "Tasks", acNormal
Else
Exit Sub
End If
End If
End Sub
您只能对一个字段执行 DCount(如果您只是对 table 进行一般计数,则主键最好)。您已输入“[Status]”,其中 Access 期望使用 table 或查询名称作为 [TaskName] 字段的来源。
有关详细信息,请参阅 here。
从您的其他代码示例来看,我希望您的代码需要:
intStore = DCount("[TaskName]", "[Tasks]", "[DueDate] <=Now() AND [Complete] =0")
我正在尝试根据从名为 "Tasks" 的 Table 添加的任务设置提醒这是我正在使用的代码,但有些地方不对,因为它一直给我带来问题以下行:
intStore = DCount("[TaskName]", "[Status]", "[DueDate] <=Now() AND [Complete] =0")
代码运行时出现错误:
Microsoft Access database engine cannot find the input table or query for 'Status' Make sure it exists and is spelled correctly.
在我的 table 中,我有 任务名称、状态 和 截止日期 所以我不确定为什么会出现这种情况。
下面是整行代码:
Private Sub Form_Load()
'On Load of the switchboard check Jobs table for any uncompleted jobs
Dim intStore As Integer
intStore = DCount("[Priority]", "[Tasks]", "[DueDate] <=Now() AND [PercentComplete] <=0")
If intStore = 0 Then
Exit Sub
Else
If MsgBox("There are " & intStore & " uncompleted jobs" & _
vbCrLf & vbCrLf & "Would you like to see these now?", _
vbYesNo, "You Have Uncomplete Jobs...") = vbYes Then
DoCmd.Minimize
DoCmd.OpenForm "Tasks", acNormal
Else
Exit Sub
End If
End If
End Sub
您只能对一个字段执行 DCount(如果您只是对 table 进行一般计数,则主键最好)。您已输入“[Status]”,其中 Access 期望使用 table 或查询名称作为 [TaskName] 字段的来源。
有关详细信息,请参阅 here。
从您的其他代码示例来看,我希望您的代码需要:
intStore = DCount("[TaskName]", "[Tasks]", "[DueDate] <=Now() AND [Complete] =0")