Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/ms-access/4.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 Access_Vba_Ms Access 2007 - Fatal编程技术网

Ms access 访问报告中的条件语句

Ms access 访问报告中的条件语句,ms-access,vba,ms-access-2007,Ms Access,Vba,Ms Access 2007,如何在报表访问中设置条件if else语句 这是报告中搜索特定数据的编码 Dim lngID As String lngID = InputBox("Enter RF No") If lngID = "" Then DoCmd.ClearMacroError Else DoCmd.OpenReport "Requisition_ReportComplete", acViewReport, , "[RF_no]=" & lngID End If 这是if-else语句的编码 Dim ln

如何在报表访问中设置条件if else语句

这是报告中搜索特定数据的编码

Dim lngID As String
lngID = InputBox("Enter RF No")
If lngID = "" Then
DoCmd.ClearMacroError
Else
DoCmd.OpenReport "Requisition_ReportComplete", acViewReport, , "[RF_no]=" & lngID
End If
这是if-else语句的编码

Dim lngID As String

lngID = InputBox("Enter RF No")
If lngID = "" Then
DoCmd.ClearMacroError
ElseIf lngID <> RF_no Then
MsgBox "Data not exist"
Else
DoCmd.OpenReport "Requisition_ReportComplete", acViewReport, , "[RF_no]=" & lngID
End If
Dim lngID作为字符串
lngID=输入框(“输入射频号”)
如果lngID=“”,则
DoCmd.ClearMacroError
如果没有,那么
MsgBox“数据不存在”
其他的
DoCmd.OpenReport“请购单报告完成”,acViewReport,“[RF\U编号]=”&lngID
如果结束

用于搜索的if-else语句不能满足我的要求。我不知道为什么…

我假设RF_no是参考号,是主键。如果RF_no只是在if语句之前定义的一个特定数字,那么代码就可以正常工作。在打开表单之前检查表中是否存在记录的一种方法是使用Dcount或Dlookup ie:

ElseIf DCount("SomeField", "YourTable", "RF_no=" & lngID) = 0 Then

ElseIf IsNull(DLookup("[Some Field]", "YourTable", "[RF_no] = " & lngID)) Then

两个都可以。他们将检查您的表中是否存在ID=lngID的记录,如果未找到任何内容,他们将打开表单。

如果我在lngID(输入框)中输入RF_no,如果记录不存在,情况如何?我是否需要使用来确定RF_是否不存在@罗伯特