Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/vba/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ms access MS访问上的筛选器出现数据类型不匹配错误_Ms Access_Vba_Ms Access 2010 - Fatal编程技术网

Ms access MS访问上的筛选器出现数据类型不匹配错误

Ms access MS访问上的筛选器出现数据类型不匹配错误,ms-access,vba,ms-access-2010,Ms Access,Vba,Ms Access 2010,我完全被难住了。这段代码正在工作,目前正在另一个数据库上工作,但在我现在正在处理的数据库上刚刚停止。当我一步一步地遍历代码时,为什么会出现“条件中的数据类型不匹配”错误?填充的所有数据都是正确的。我在这里得到错误:FilterOn=True。我不知道如何调试此代码或如何修复它 以下是完整的代码供参考: Me.searchlat = TempVars("user").Value Dim strWhere As String Dim lngLen As Long Const conJetDate

我完全被难住了。这段代码正在工作,目前正在另一个数据库上工作,但在我现在正在处理的数据库上刚刚停止。当我一步一步地遍历代码时,为什么会出现“条件中的数据类型不匹配”错误?填充的所有数据都是正确的。我在这里得到错误:
FilterOn=True
。我不知道如何调试此代码或如何修复它

以下是完整的代码供参考:

Me.searchlat = TempVars("user").Value
Dim strWhere As String
Dim lngLen As Long

 Const conJetDate = "\#mm\/dd\/yyyy\#"

 If Not IsNull(Me.searchlat) Then
 strWhere = strWhere & "([workerid] = " & Me.searchlat & " ) AND "
    End If

If Not IsNull(Me.txtStartDate) Then
strWhere = strWhere & "([Dateassigned] >= " & Format(Me.txtStartDate, conJetDate) & ") AND "
    End If

If Not IsNull(Me.txtEndDate) Then
strWhere = strWhere & "([Dateassigned]< " & Format(Me.txtEndDate + 1,   conJetDate) & ") AND "
   End If

 lngLen = Len(strWhere) - 5
 If lngLen <= 0 Then
 MsgBox "No criteria", vbInformation, "Nothing to do."
 Else
 strWhere = Left$(strWhere, lngLen)

 Me.Filter = strWhere
 Me.FilterOn = True
Me.searchlat=TempVars(“用户”).Value
作为字符串的Dim strWhere
幽幽幽幽
Const congetdate=“\\\\ mm\/dd\/yyyy\\”
如果不为null(Me.searchlat),则
strWhere=strWhere&“([workerid]=”&Me.searchlat&“)和”
如果结束
如果不为null(Me.txtStartDate),则
strWhere=strWhere&“([Dateassigned]>=”&Format(Me.txtStartDate,congetdate)&”)和”
如果结束
如果不为null(Me.txtEndDate),则
strWhere=strWhere&“([Dateassigned]<”&格式(Me.txtEndDate+1,congetDate)和”
如果结束
lngLen=Len(strWhere)-5

如果lngLen错误本身表明标准中的数据类型不匹配

在条件中,您正在检查日期和ID。日期格式与第一次查看时的格式相同,因此最好将
放在ID上,并按以下方式进行检查

Me.searchlat = TempVars("user").Value
Dim strWhere As String
Dim lngLen As Long

 Const conJetDate = "\#mm\/dd\/yyyy\#"

 If Not IsNull(Me.searchlat) Then
 strWhere =  " ([workerid] = '" & Me.searchlat & "' )  "
    End If

If Not IsNull(Me.txtStartDate) Then
strWhere = strWhere & " AND ([Dateassigned] >= " & Format(Me.txtStartDate, conJetDate) & ")  "
    End If

If Not IsNull(Me.txtEndDate) Then
strWhere = strWhere & " AND ([Dateassigned]< " & Format(Me.txtEndDate + 1,   conJetDate) & ")  "
   End If

 lngLen = Len(strWhere) - 5
 If lngLen <= 0 Then
 MsgBox "No criteria", vbInformation, "Nothing to do."
 END IF

 Me.Filter = strWhere
 Me.FilterOn = True
Me.searchlat=TempVars(“用户”).Value
作为字符串的Dim strWhere
幽幽幽幽
Const congetdate=“\\\\ mm\/dd\/yyyy\\”
如果不为null(Me.searchlat),则
strWhere=“([workerid]=”&Me.searchlat&“)”
如果结束
如果不为null(Me.txtStartDate),则
strWhere=strWhere&“和([Dateassigned]>=”&格式(Me.txtStartDate,congetdate)&“)
如果结束
如果不为null(Me.txtEndDate),则
strWhere=strWhere&“和([Dateassigned]<”&格式(Me.txtEndDate+1,congetDate)&”)
如果结束
lngLen=Len(strWhere)-5

如果lngLen在13个小时后重新编写此代码,您就是一个救生员!!