KEFAH2009 قام بنشر مارس 18, 2009 قام بنشر مارس 18, 2009 عندى أسم المستخدم يظهر فى النموزج أتوماتيكى بمجرد عمل لوق كيف أخلية يتسجل فى الجدول التابع للنموزج حيت أنة ليس لة عمود فى الجدول أية الحل 454
Bluemind قام بنشر مارس 18, 2009 قام بنشر مارس 18, 2009 (معدل) اخوي قم بانشاء وحده نمطيه او module وضع الكود التالي فيه Option Compare Database Private Declare Function apiGetUserName Lib "advapi32.dll" Alias "GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long Public Function StampRecord(frm As Form, Optional bHasInactive As Boolean = False) As Boolean On Error GoTo Err_StampRecord 'Purpose: Stamp the user and date/time into the record. 'Return: True if successful. 'Argument: frm = the bound form to be stamped. ' bHasInactive= True if the form has Inactive fields. 'Assumes: Fields named EnteredOn, EnteredBy, UpdatedOn, and UpdatedBy. 'Usage: In Form_BeforeUpdate: ' Call StampRecord(Me, True) Dim strForm As String Dim strUser As String strForm = frm.Name 'For error handler. strUser = NetworkUserName() If frm.NewRecord Then frm!EnteredBy = strUser End If If bHasInactive Then With frm!Inactive If .Value = .OldValue Then 'do nothing Else If .Value Then frm!InactiveBy = strUser Else frm!InactiveBy = Null End If End If End With End If Exit_StampRecord: Exit Function Err_StampRecord: Call LogError(Err.Number, Err.Description, conMod & "StampRecord()", "Form = " & strForm) Resume Exit_StampRecord End Function Public Function LogError(ByVal lngErrNumber As Long, ByVal strErrDescription As String, _ strCallingProc As String, Optional vParameters, Optional bShowUser As Boolean = True) As Boolean On Error GoTo Err_LogError ' Purpose: Generic error handler. ' Arguments: lngErrNumber - value of Err.Number ' strErrDescription - value of Err.Description ' strCallingProc - name of sub|function that generated the error. ' bShowUser - optional boolean: If False, suppresses display. ' vParameters - optional string: List of parameters to record. Dim strMsg As String ' String for display in MsgBox Select Case lngErrNumber Case 0 Debug.Print strCallingProc & " called error 0." Case 2501 'cancelled. 'Do nothing. Case 3314, 2101, 2115 'can't save. If bShowUser Then strMsg = "Record cannot be saved at this time." & vbCrLf & "Complete the entry, or press <Esc> to undo." MsgBox strMsg, vbExclamation, strCallingProc End If Case Else If bShowUser Then strMsg = "Error " & lngErrNumber & ": " & strErrDescription MsgBox strMsg, vbExclamation, strCallingProc End If End Select LogError = True Exit_LogError: On Error GoTo 0 Exit Function Err_LogError: strMsg = "An unexpected situation arose in your program." & vbCrLf & _ "Please write down the following details:" & vbCrLf & vbCrLf & _ "Calling Proc: " & strCallingProc & vbCrLf & _ "Error Number " & lngErrNumber & vbCrLf & strErrDescription & vbCrLf & vbCrLf & _ "Unable to record because Error " & Err.Number & vbCrLf & Err.Description MsgBox strMsg, vbCritical, "LogError()" Resume Exit_LogError End Function Public Function NetworkUserName() As String On Error GoTo Err_Handler 'Purpose: Returns the network login name. Dim lngLen As Long 'Length of string. Dim strUserName As String Const lngcMaxFieldSize As Long = 50& 'Length of field to store this data. 'Initialize NetworkUserName = "Unknown" strUserName = String$(254, 0) lngLen = 255& 'API returns a non-zero value if success. If apiGetUserName(strUserName, lngLen) > 0& Then lngLen = lngLen - 1& 'Without null termination char. If lngLen > lngcMaxFieldSize Then 'Maximum field size lngLen = lngcMaxFieldSize End If NetworkUserName = Left$(strUserName, lngLen) End If Exit_Handler: Exit Function Err_Handler: Call LogError(Err.Number, Err.Description, conMod & ".NetworkUserName", , False) Resume Exit_Handler End Function بعد ذلك قم بانشاء الحقل في جدولك وسمه EnteredBy بعد ذلك في حدث قبل التحديث او before update قم بوضع هذا الكود Call StampRecord(Me, False) طبعا اذا حبيت تستخدم الحقل الموجود لديك في الجدول يجب عليك تغيير في الكو الموجود في الوحده النمطيه وتحديدا هنا: frm!EnteredBy = strUser تم تعديل مارس 18, 2009 بواسطه Bluemind
KEFAH2009 قام بنشر مارس 18, 2009 الكاتب قام بنشر مارس 18, 2009 مشكور يا أخوى أن شاء اللة فى ميزان حسناتك
الردود الموصى بها
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.