Hi! In this article I will show you how to customize MsgBox represent in Khmer Unicode display form in VBA Microsoft Access. I find more website about this post but I can't find solution good for me. but now I can customize and show you. Let's follow my step:
1. Create New Database called "CustomKhmerMessageBox"
2. I created New table called "KhmerMessage" it have some fields ( smg_Type,smgKey,msgVal)
like show in picture
3. I create Module called module1 and follow this code
'Msgbox content
Public MSG_Color As Long
Public msgUniText As String
Public msgUniReturn As Integer
- I created Enum for switch Message Type
Public Enum KhmerMessage
khOK = 1
khCancel = 2
khyes = 3
khNo = 4
End Enum
- And I created public variable for response from user invoke from Message Form
Public KhmerMessageResponse As KhmerMessage
- And I created function:
Public Function UNICODE_DIALOG_YesNo_Enum(Optional ByVal msg_Type As Integer = 0, Optional ByVal args1 As String = "", _
Optional ByVal args2 As String = "", _
Optional ByVal args3 As String = "", _
Optional ByVal args4 As String = "", _
Optional ByVal args5 As String = "") As KhmerMessage
Dim strSQL As String
Dim dbs As Database
Dim rst As Recordset
Set dbs = CurrentDb
Set rst = dbs.OpenRecordset("SELECT * FROM KhmerMessageBox WHERE msg_TYPE=" & msg_Type)
If rst.RecordCount <= 0 Then
MsgBox "Can't Load the Unicode message DIALOG_YesNo from database, please contact the system administrator!!!", vbCritical
rst.Close
Exit Function
End If
msgUniText = ""
msgUniText = rst![msgVal]
msgUniText = Replace(msgUniText, "{[$1]}", args1)
msgUniText = Replace(msgUniText, "{[$2]}", args2)
msgUniText = Replace(msgUniText, "{[$3]}", args3)
msgUniText = Replace(msgUniText, "{[$4]}", args4)
msgUniText = Replace(msgUniText, "{[$5]}", args5)
rst.Close
DoCmd.OpenForm "frm_message_YesNo", , , , , acDialog
UNICODE_DIALOG_YesNo_Enum = KhmerMessageResponse
End Function
In form Message follow this code:
Option Compare Database
Option Explicit
Private Sub Command2_Click()
ModuleKhmerMessageBox.KhmerMessageResponse = khyes
DoCmd.Close
End Sub
Private Sub Command3_Click()
ModuleKhmerMessageBox.KhmerMessageResponse = khNo
DoCmd.Close
End Sub
Private Sub Form_Load()
Text0.Value = ModuleKhmerMessageBox.msgUniText
Text0.ForeColor = MSG_Color
Text0.TextFormat = acTextFormatHTMLRichText
End Sub