Minh Tiên > 06-10-13, 01:02 PM
paulsteigel > 06-10-13, 02:55 PM
Minh Tiên > 06-10-13, 09:11 PM
khải nguyên > 06-10-13, 09:40 PM
paulsteigel > 06-10-13, 09:50 PM
(06-10-13, 09:11 PM)tmtien261 Đã viết: Cảm ơn "paulsteigel". Cách của bạn Pro quá. Mình sẽ nghiên cứu làm theo. Việc gõ một bảng các thông điệp vào Table và sau đó gọi tìm đưa ra Msgbox mình cũng đã làm. Xong phải tra đi, tra lại nhiều lần, mỏi quá nên mình mới cho nó vào thẳng luôn, mỗi lần làm đến đâu, thích gì thì ghi nấy đỡ mệt hà hà !
...
Function GETMSG(MSG_ID As String, Optional Langguage As String = "Vi") As String
Dim iLng As Recordset
If iMesage = "" Then iMesage = "SYS_MESSAGE"
Set iLng = CurrentDb.OpenRecordset("Select [Caption" & Langguage & "] from Caption where MSG_ID ='" & MSG_ID & "';")
If iLng.EOF Then
GETMSG = "Message has not been defined!"
Else
GETMSG = iLng.Fields(0)
End If
iLng.Close
End Function
Minh Tiên > 07-10-13, 10:19 AM
paulsteigel > 07-10-13, 02:39 PM
Sub testInsert()
Dim SqlTxt As String
SqlTxt = "INSERT INTO tblSoKTMay ( DienGiaiChiTiet, SoHieuTK, MaSo, SoLuongPS, DonGiaPS, SoPSNo, SoPSCo ) " & _
"SELECT a.DienGiaiChiTiet, a.SoHieuTK, a.MaSo, a.SoLuongPS, a.DonGiaPS, a.SoPSNo, a.SoPSCo " & _
"FROM tblTMP as a;"
CurrentDb.Execute SqlTxt
End Sub
Minh Tiên > 07-10-13, 09:18 PM
paulsteigel > 07-10-13, 11:23 PM
Option Explicit
'=======================================================
' Module for Vietnamized MsgBox function
' This overide default VBA MsgBox function with some small
' modifications of text, button caption....
' Use this MsgBox function like it is in default VBA IDE
'=======================================================
' Import
Private Declare Function GetCurrentThreadId Lib "kernel32" () As Long
Private Declare Function SetDlgItemText Lib "user32" _
Alias "SetDlgItemTextW" _
(ByVal hDlg As Long, _
ByVal nIDDlgItem As Long, _
ByVal lpString As String) As Long
Private Declare Function SetWindowsHookEx Lib "user32" _
Alias "SetWindowsHookExA" _
(ByVal idHook As Long, _
ByVal lpfn As Long, _
ByVal hmod As Long, _
ByVal dwThreadId As Long) As Long
Private Declare Function UnhookWindowsHookEx Lib "user32" _
(ByVal hHook As Long) As Long
' Handle to the Hook procedure
Private hHook As Long
' Hook type
Private Const WH_CBT = 5
Private Const HCBT_ACTIVATE = 5
' Constants
Public Const IDOK = 1
Public Const IDCANCEL = 2
Public Const IDABORT = 3
Public Const IDRETRY = 4
Public Const IDIGNORE = 5
Public Const IDYES = 6
Public Const IDNO = 7
'=======================================================
'The following enums were taken from MSO type.
'=======================================================
Public Enum MsoAlertIconType
msoAlertIconCritical = 1
msoAlertIconInfo = 4
msoAlertIconNoIcon = 0
msoAlertIconQuery = 2
msoAlertIconWarning = 3
End Enum
Public Enum MsoAlertButtonType
msoAlertButtonAbortRetryIgnore = 2
msoAlertButtonOK = 0
msoAlertButtonOKCancel = 1
msoAlertButtonRetryCancel = 5
msoAlertButtonYesAllNoCancel = 6
msoAlertButtonYesNo = 4
msoAlertButtonYesNoCancel = 3
End Enum
Public Enum MsoAlertDefaultType
msoAlertDefaultFifth = 4
msoAlertDefaultFirst = 0
msoAlertDefaultFourth = 3
msoAlertDefaultSecond = 1
msoAlertDefaultThird = 2
End Enum
Public Enum MsoAlertCancelType
msoAlertCancelDefault = -1
msoAlertCancelFifth = 4
msoAlertCancelFirst = 0
msoAlertCancelFourth = 3
msoAlertCancelSecond = 1
msoAlertCancelThird = 2
End Enum
'===================================
' Modify this code for English
Private StrYes As String
Private StrNo As String
Private StrOK As String
Private StrCancel As String
' Application title
Private Const App_Title = "MsgBox Demo function..."
Function MsgBox(MessageTxt As String, Optional msgStyle As VbMsgBoxStyle) As VbMsgBoxResult
Beep
Dim iVal As VbMsgBoxStyle, msgBoxIcon As MsoAlertIconType, msgButton As MsoAlertButtonType
iVal = msgStyle
Select Case msgStyle
Case 20, 19, 17, 16: ' Critical case
iVal = iVal - 16
msgBoxIcon = msoAlertIconCritical
Case 36, 35, 33, 32: ' Question case
iVal = iVal - 32
msgBoxIcon = msoAlertIconQuery
Case 52, 51, 49, 48: ' Exclamation case
iVal = iVal - 48
msgBoxIcon = msoAlertIconWarning
Case 68, 67, 65, 64: ' Information case
iVal = iVal - 64
msgBoxIcon = msoAlertIconInfo
End Select
Select Case iVal
Case 4:
msgButton = msoAlertButtonYesNo
Case 3:
msgButton = msoAlertButtonYesNoCancel
Case 1:
msgButton = msoAlertButtonOKCancel
Case 0:
msgButton = msoAlertButtonOK
End Select
' Set Hook
hHook = SetWindowsHookEx(WH_CBT, AddressOf MsgBoxHookProc, 0, GetCurrentThreadId)
' Display the messagebox
MsgBox = Application.Assistant.DoAlert(App_Title, MessageTxt, msgButton, msgBoxIcon, msoAlertDefaultFirst, msoAlertCancelDefault, True)
End Function
Private Function MsgBoxHookProc(ByVal lMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
If lMsg = HCBT_ACTIVATE Then
StrYes = "&C" & ChrW(243)
StrNo = "&Kh" & ChrW(244) & "ng"
'StrOK = ChrW(272) & ChrW(7891) & "&ng " & ChrW(253)
StrOK = "Ch" & ChrW(7845) & "p nh" & ChrW(7853) & "&n"
StrCancel = "&H" & ChrW(7911) & "y"
SetDlgItemText wParam, IDYES, StrConv(StrYes, vbUnicode)
SetDlgItemText wParam, IDNO, StrConv(StrNo, vbUnicode)
SetDlgItemText wParam, IDCANCEL, StrConv(StrCancel, vbUnicode)
SetDlgItemText wParam, IDOK, StrConv(StrOK, vbUnicode)
' Release the Hook
UnhookWindowsHookEx hHook
End If
MsgBoxHookProc = False
End Function
Minh Tiên > 11-10-13, 05:54 PM