Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/reporting-services/3.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 尝试跳转/转到VBA中代码的不同部分_Ms Access_Vba - Fatal编程技术网

Ms access 尝试跳转/转到VBA中代码的不同部分

Ms access 尝试跳转/转到VBA中代码的不同部分,ms-access,vba,Ms Access,Vba,我相信这很容易,但我似乎无法在网上找到答案,除了GoTo Record,这不是我想要的 基本上,我的VBA会检查该唯一键是否存在,如果存在,它会显示一个消息框,然后我希望它跳到代码的底部。现在它只是转到下一行开始添加记录 这里是我现在拥有的: With myR .FindFirst ("Username = '" & Me.UID & "'") If .NoMatch Then Else MsgBox "That username

我相信这很容易,但我似乎无法在网上找到答案,除了GoTo Record,这不是我想要的

基本上,我的VBA会检查该唯一键是否存在,如果存在,它会显示一个消息框,然后我希望它跳到代码的底部。现在它只是转到下一行开始添加记录

这里是我现在拥有的:

With myR

    .FindFirst ("Username = '" & Me.UID & "'")

    If .NoMatch Then

    Else

        MsgBox "That username is already in the system."

        'Add skip to bottom code here 

    End If

End With
进一步感谢我的评论

Sub Main()

    isA1Empty

End Sub


Private Function isA1Empty()
    With Sheets(1)
        If IsEmpty(.Range("A1")) Then
            MsgBox "empty"
            Exit Function
            Debug.Print "this will not be printed"
        End If
    End With
End Function

如果将其包装在函数中,则可以使用
退出函数
或将其包装在子函数中使用
退出子函数
是的,您是对的。我完全忘记了退出子系统。这就是当你从3个月前开始一个项目时发生的事情。谢谢