简体   繁体   English

MS-Access自动更新表格不断更改按钮的可见性

[英]MS-Access Auto update form constantly to change visibility of a button

still strugling with an access database for a quality control system. 仍在为质量控制系统争用访问数据库。

My last question was to have a button visibility and enable properties change to 0 if a condition wasnt met. 我的最后一个问题是具有按钮可见性,并且如果不满足条件,则将属性更改为0。 I was able to do this with the following code: 我可以使用以下代码执行此操作:

Private Sub Form_Current()

Dim ok As Boolean
ok = Status.Value


Botão_Motores.Visible = ok
Botão_Motores.Enabled = ok

End Sub

But the problem now is that it only updates the status when i open and close the form, not when the Status field updates... My approach here, although im open to other strategies is to include somthing in the Change sub of the Status field to run the code in the form_current sub, is this possible or do i have to do it in another way? 但是现在的问题是,它仅在我打开和关闭表单时更新状态,而不是在“状态”字段更新时更新...我在这里的方法,尽管我对其他策略开放是在“状态”字段的“更改”子句中包含其他内容在form_current子代码中运行代码,这可能还是我必须以另一种方式来做? if so, how? 如果是这样,怎么办?

Thank you 谢谢

Access has no event for a datachange in the form - just for the first time the user changed any data on the form (dirty) and for record change(current) and for datachanges in the controls (Dirty, Change, BeforeUpdate,AfterUpdate...) Access没有发生任何形式的数据更改事件-仅是第一次用户更改了表单上的任何数据(脏),记录更改(当前)以及控件中的数据更改(脏,更改,BeforeUpdate,AfterUpdate。)。 )

You can make a procedure for that task and call it from Current and from the appropriate event (probably AfterUpdate) of the controls that should change the visibility of your button. 您可以为该任务制定一个过程,并从Current和应该更改按钮可见性的控件的适当事件(可能是AfterUpdate)中调用它。

Private Sub ChangeMotorVisibility()
   Botao_Motores.visible=Status.value
End Sub

Private Sub Form_Current()
  ChangeMotorVisibility
End Sub

Private Sub Status_AfterUpdate()
  ChangeMotorVisibility
End Sub

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM