退出如果保存,需要有关vba代码的帮助 [英] exit if saved, need help on vba code

查看:97
本文介绍了退出如果保存,需要有关vba代码的帮助的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有"保存"和"退出"访问表单中的按钮。点击"退出"按钮按钮如果"保存"按钮已被点击然后关闭表格其他msgbox,需要保存与否。如果是,则保存并关闭表单。 

I have "save" and "exit" button in access form. on clicking "Exit" button if "save" button is already clicked then close the form else msgbox, need to save or not. If yes then save it and close the form. 

我的代码:

在此代码中,出现错误  "Me.CmdSave = True然后"是无效的代码。那么适当的代码是什么呢?如果有人尽快给我答案,我将不胜感激。

In this code, there is a error  "Me.CmdSave = True Then" is not valid code. So what will be the proper code for it? I will be grateful if someone give me the answer asap.

推荐答案

一个方法是使用Form变量。在"保存"按钮的Click事件中,您可以将其设置为True。在Exit按钮的Click事件中,您可以检查变量是否为True。

One approach is to use a Form variable. In the Click event of the Save button, you can set it to True. In the Click event of the Exit button, you can check if the variable is True or not.

因此,在Save按钮的Click事件中:

So, in the Click event of the Save button:

FormVariableName = True

FormVariableName=True

在退出按钮的Click事件中:

And in the Click event of the Exit button:

如果FormVariableName = True则

If FormVariableName=True Then

希望它有所帮助......

Hope it helps...


这篇关于退出如果保存,需要有关vba代码的帮助的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆