vba 增加 Microsoft Access 2013 中消息框的字体大小
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/23892754/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Increase the font size of message box in Microsoft Access 2013
提问by user2652375
Is it possible to increase the font size of message box in Access 2013 via vba code?
是否可以通过 vba 代码增加 Access 2013 中消息框的字体大小?
From this
由此
to this
对此
Some users are over 40 years old. They require a bigger size of font for viewing. Thanks!
一些用户超过 40 岁。他们需要更大的字体来查看。谢谢!
回答by guitarthrower
The font size of system error boxes is a system control and would need to be changed on all individual computers.
系统错误框的字体大小是系统控制,需要在所有单独的计算机上更改。
You could instead trap the error in VBA and display your own messages via a UserForm, which would allow you to control the message and the font.
您可以改为在 VBA 中捕获错误并通过用户窗体显示您自己的消息,这将允许您控制消息和字体。
So, instead of
所以,而不是
If countDuplicate > 0 Then
MsgBox _
"A record of this Part ID already exist. No changes can be made.", _
vbCritical, _
"Duplicated Record"
Me.Undo
End If
You would have the following:
您将拥有以下内容:
If countDuplicate > 0 Then
frm_AlreadyExists.Show
Me.Undo
End If
Where frm_AlreadyExists
is a form that you would create and would have the message you listed above.
frm_AlreadyExists
您将创建的表单在哪里,并包含上面列出的消息。
That should get you started. As a further step, instead of having a separate UserForm
for each error, you could create an error table that would contain Error ID
, Error Message
, Error Type
, Error Title
columns.
这应该让你开始。作为进一步的步骤,UserForm
您可以创建一个包含Error ID
, Error Message
, Error Type
,Error Title
列的错误表,而不是为每个错误单独设置一个。
Error ID Error Message Error Type Error Title Button Action Button Text
1 A record ... already exist. Critical Duplicated Record SubName1 Click Here
2 ... not a valid EMPLOYEE Critical Invalid GID SubName2 Click Here
Then you would call the UserForm
with the following:
然后,您将UserForm
使用以下内容调用:
If countDuplicate > 0 Then
ErrorID = 1 'You'll need to declare this variable elsewhere in your code
frm_AlreadyExists.Show
End If
And the code to initialize the UserForm
(in the UserForm code module)
以及初始化UserForm
(在用户窗体代码模块中)的代码
Private Sub UserForm_Initialize()
Dim lErrorID As Long
Dim sErrorMessage As String
Dim sErrorType As String
Dim sErrorTitle As String
Dim sBtnText As String
lErrorID = errorID
''Look up the following from the Error Table
'sErrorMessage = Result from lookup
'sErrorType = Result from lookup
'sErrorTitle = Result from lookup
'sBtnText = Result from lookup
Me.lbl_ErrorMessage = sErrorMessage
Me.img_ErrorType.Picture = "C:/File Location/" & sErrorType & ".jpg"
Me.Caption = sErrorTitle
Me.btn_Action.Caption = sBtnText
End Sub
And the code for the button click
和按钮点击的代码
Private Sub btn_Action_Click()
Dim sBtnAction As String
''Look up the following from the Error Table
'sBtnAction = Result from lookup
Application.Run sBtnAction
End Sub
With this and some tweaking and messing with code, you can now have a custom error/message system that would allow you (or even the user) to set the font for the messages.
有了这个和一些调整和弄乱代码,您现在可以拥有一个自定义错误/消息系统,允许您(甚至用户)设置消息的字体。