2016-09-14 29 views
-5

对于VBA Access 2010中的字段/对象的“带到前面”或“发回”以下代码是否正确?“带到前面”或“发回”的代码是否正确?

我的代码是:

Private Sub Report_Load() 

If IsOpen("Details_ME") Then 

    Me.Controls("DRAFT_Logo").InSelection = True 
    DoCmd.RunCommand acCmdBringToFront 
Else 

    Me.Controls("DRAFT_Logo").InSelection = True 
    DoCmd.RunCommand acCmdSendToBack 

End If 

End sub 

VBA显示在下面的代码黄色错误:

Me.Controls("DRAFT_Logo").InSelection = True 

任何帮助或建议表示赞赏

+1

黄色的亮点仅仅意味着这就是当前执行的线,它本身不是一个错误,这是调试器的只是一个特性 - 什么是*实际*错误消息,”重新获得? –

回答

0

我做了一点修正,这是有用的,所以它工作正常:)

我应该把代码为“当前事件”我而不是“加载事件”。

Private Sub Report_Current() 

If IsOpen("Details_ME") Then 

    Me.Controls("DRAFT_Logo").InSelection = True 
    DoCmd.RunCommand acCmdBringToFront 

Else 

    Me.Controls("DRAFT_Logo").InSelection = True 
    DoCmd.RunCommand acCmdSendToBack 

End If 

End Sub 

谢谢你......