将焦点从子窗体设置为MainForm [英] Set Focus from Subform to MainForm

查看:94
本文介绍了将焦点从子窗体设置为MainForm的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下代码。尝试将焦点从子窗体设置为主窗体时,我一直收到错误。


如果抗议#为空,我不希望保存数据。抗议号码在主表单上


以下代码在Subform上。我有错误粗体:


错误MSG:无法将焦点移动到控件


请帮忙!


私人子Form_BeforeUpdate(取消为整数)

 如果Len(Me.PROTEST_NUMBER&"")= 0则为
    MsgBox"输入抗议号码",vbOKOnly,"抗议号码"

        取消=真实
Me.Parent.Form.SetFocus

Me.Parent.Form.PROTEST_NUMBER.SetFocus


 

结束如果

结束子



谢谢!!!




$


$



解决方案


只是想一想......为什么不把代码放在子窗体的Enter事件中?这意味着,如果您要阻止他们在抗议号码为空白时保存它,请不要让用户输入子表单中的任何内容。


只需我2美分......


I have the below code. I keep getting error when trying to set the focus from the subform to the main form.

I don't want the data to save if the protest# is blank. The protest number is on the main form

The below code is on the Subform. I have the error bolded:

Error MSG: Cannot move focus to the control

Please help!

Private Sub Form_BeforeUpdate(Cancel As Integer)
  If Len(Me.PROTEST_NUMBER & "") = 0 Then
    MsgBox "Enter Protest Number", vbOKOnly, "protest Number"
         Cancel = True
Me.Parent.Form.SetFocus
Me.Parent.Form.PROTEST_NUMBER.SetFocus

 
End If
End Sub

Thanks!!!

解决方案

Hi,

Just a thought... Why not put the code in the Enter event of the subform? Meaning, don't let the user enter anything in the subform if you're going to prevent them from saving it anyway when the protest number is blank.

Just my 2 cents...


这篇关于将焦点从子窗体设置为MainForm的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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