【问题标题】:Increase the font size of message box in Microsoft Access 2013在 Microsoft Access 2013 中增加消息框的字体大小
【发布时间】:2014-07-16 13:30:53
【问题描述】:

Access 2013可以通过vba代码增加消息框的字体大小吗?

从这里

到这里

有些用户已超过 40 岁。他们需要更大尺寸的字体才能查看。谢谢!

【问题讨论】:

    标签: ms-access vba ms-access-2010 ms-access-2013


    【解决方案1】:

    系统错误框的字体大小是系统控件,需要在所有单独的计算机上进行更改。

    您可以改为在 VBA 中捕获错误并通过用户窗体显示您自己的消息,这将允许您控制消息和字体。

    所以,而不是

    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
    

    您将拥有以下内容:

    If countDuplicate > 0 Then
        frm_AlreadyExists.Show
        Me.Undo
    End If
    

    frm_AlreadyExists 是您将创建的表单,其中包含您在上面列出的消息。

    这应该让你开始。作为进一步的步骤,您可以创建一个包含 Error IDError MessageError TypeError Title 列的错误表,而不是为每个错误单独创建一个 UserForm

    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
    

    然后您将使用以下内容调用UserForm

    If countDuplicate > 0 Then
        ErrorID = 1 'You'll need to declare this variable elsewhere in your code
        frm_AlreadyExists.Show
    End If
    

    以及初始化UserForm的代码(在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
    

    以及按钮点击的代码

    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
    

    通过这个以及一些调整和代码混乱,您现在可以拥有一个自定义错误/消息系统,允许您(甚至用户)设置消息的字体。

    【讨论】:

    • 感谢您的回答。如果我不能很好地理解您的回答,请原谅我。首先,您的意思是Access Form中的MsgBox =系统错误框吗?我认为是的。我在Windows 8上试过。消息框字体大小可以更改(开始->控制面板->外观和个性化->字体->更改字体大小->从组合框中选择消息框,其中标题栏是默认选择,然后选择旁边的字体大小,范围从 6 到 24。然后单击应用)。但我无法在 Windows 7 中找到相同的目的地。您能告诉我路径吗?
    • 其次,我是 VBA 的初学者。我不太理解您在“在 VBA 中捕获错误并通过用户窗体显示您自己的消息,这将允许您控制消息和字体”中的替代方案。您能否向我展示代码示例或将我引导到提供相关信息的网站。我无法从谷歌获得它。非常感谢。
    • 对第一条评论的回应:都是一样的,只是它允许您按百分比更改,而不是特定大小。但就像我提到的那样,这不是一个好的答案,因为每个用户都必须进行此更改,而且由于它是系统范围的,他们可能不想进行此更改。
    • 要向您展示代码,您需要展示一些您的代码。你是怎么得到消息框的?这是一个错误吗?它是您正在运行的代码的结果,还是正在采取的其他操作?一旦我们知道您可以用 UserForm 替换消息(请参阅 VBA 环境 Insert > UserForm)。
    • 有些只是普通的消息框,如:MsgBox "Add new part in NEW PART Table.", vbInformation, "Add New Part";有些是为了错误处理,比如: If countDuplicate > 0 Then MsgBox "A record of this Part ID already exists. No changes can be made.", vbCritical, "Duplicated Record" Me.Undo End If;如果 countName = 0 那么 MsgBox " " & [txtGID] & " 不是有效的 EMPLOYEE。" & " Re-enter GID", vbCritical, "Invalid GID" txtGID = Null dummy.SetFocus txtGID.SetFocus End If
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-05-14
    • 2013-12-26
    • 2011-09-05
    • 2010-09-20
    • 1970-01-01
    • 2022-11-14
    • 2015-02-03
    相关资源
    最近更新 更多