主题: 信息: Access 2000格式消息框
(原始发布时间99年9月30日)
在Access 97中,消息框功能有个提供文档的语法,利用 @ 符号来创建格式消息框,例如,如果助手被打开,它会使用Office 助手(Office Assistant)。你可以使用以下(从Access 97帮助)的:
MsgBox "Wrong button!@This button doesn't work.@Try another.", _
vbOKOnly + vbExclamation
在Access 2000中(它综合了VBE和 Visual Basic 编辑器),VBA消息框功能不能回调到Access做这个工作,因此,你就丢失了格式消息框,而且你也会丢失使Office Assistant置“前”用于消息的能力。但是,要有一个工作区!
通过使用Eval功能,你的调用将通过与Access 和 Jet接口的表达式服务来运行消息框功能,它将会调入Access版本而不是VBA版本。因此,你可以添加以下的内容到你的Access数据库,并调用它而不是VBA消息框而返回到97的功能性:
Function FormattedMsgBox( _
Prompt As String, _
Optional Buttons As VbMsgBoxStyle = vbOKOnly, _
Optional Title As String = vbNullString, _
Optional HelpFile As Variant, _
Optional Context As Variant) _
As VbMsgBoxResult
If IsMissing(HelpFile) Or IsMissing(Context) Then
FormattedMsgBox = Eval("MsgBox(""" & Prompt & _
""", " & Buttons & ", """ & Title & """)")
Else
FormattedMsgBox = Eval("MsgBox(""" & Prompt & _
""", " & Buttons & ", """ & Title & """, """ & _
HelpFile & """, " & Context & ")")
End If
End Function
这里是差异。我让你决定你更喜欢哪一个:
|
MsgBox "Wrong button!@This button doesn't work.@Try Another.",
vbOKOnly + vbExclamation, "My Application"
|
|
FormattedMsgBox "Wrong button!@This button doesn't work.@Try Another.",
vbOKOnly + vbExclamation, "My Application"
|
关于本站点的问题,评论和建议,请与
webmaster@trigeminal.com联系。
| |