اذهب الي المحتوي
أوفيسنا

تصميم قاعدة بيانات احترافيه لإدارة يوميات وشئون العاملين


ابو جودي

الردود الموصى بها

السلام عليكم ورحمة الله تعالى وبركاته

نظرا للطلب والتساؤلات الكثيرة حول الموضوع او نقاط فرعيه منه قاصدا من ذلك أن يكون الموضوع شاملا ومرجعا للراغبين فى ذلك والدراسبن 

اليكم بناء القاعدة والذى اتمنى على الله تعالى ان يبدأ البناء وينتهى بشكل احترافى بقدر الإمكان وسوف نبدأ من الصفر تباعا ان شاء الله

سوف يتم تحديث الموضوع تباعا 

الموضوع بأمر الله سوف اضع له الخطوط العريضة طبقا للمؤسسة التى اعمل بها لاننى أصلا سوف اقوم بقاعدة البيانات لمؤسستى وبقدر الإمكان

سوف أضع فى الحسبان ان يكون التصميم عام بقدر الإمكان ليتناسب ويتماشى مع الجميع ومع رغباتهم بقدر الإمكان

اهلا بكل من يريد المشاركة فى ادراة الموضوع والافكار والتعديل او الاضافة و ......

مبدئيا خلونا نتفق وقتى ضيق فى الفترة المقبلة لما انا مقدم عليه فلذلك ارجو الاعتذار مقدما ان لم التفت الى اى تساؤلات والتى وإن حدث سوف يتم تأجيلها

حتى ينتهى مشروع اعداد التطبيق لمؤسستى تماما ان شاء الله

بسم الله وعلى بركة الله بداية المشروع

اول شئ تصيد وتسجيل الاخطاء بجدول 

وده وظيفته تسجيل الحطأ باسم الحدث أو الدالة المستخدمة فى الكود عند تنفيذ امر ما ورقم الخطا وصفه للمساعدة مستقبلا فى الوقوف على

اماكن الاخطاء لعمل الصيانة اللازمة

طبعا تم التطرق اليه فى هذا الموضوع:  ويمكنكم الذهاب اليه والمتابعة من هنا

طيب حلو جدا جدا 

وعلشان انا هبدأ بالأكواد 
 

ملاحظات هامة جدا جدا جدا جدا لبداية صحيحة واحترافيه :

كتابة كود احترافي تتطلب ممارسات جيدة واتباع مبادئ برمجية صحيحة. فيما يلي بعض النصائح التي يمكن أن تساعدك في كتابة كود احترافي:

  1. توضيح الكود:

    • استخدم تعليقات لشرح الجزء العلوي من الكود وللأمور المعقدة.
    • اختر أسماء مفيدة وواضحة للمتغيرات والدوال تدل على وظائفها التى تمت كتابتها من اجلها.
  2. التنظيم:

    • استخدم الهندسة المعمارية لتنظيم البرنامج إلى وحدات صغيرة وقابلة لإعادة الاستخدام.
    • قم بتقسيم البرنامج إلى وحدات ووظائف مستقلة.
  3. الأداء:

    • ابتعد عن الأكواد المكررة وقدّم الأكواد القابلة لإعادة الاستخدام في وحدات.
    • حافظ على الأداء بتجنب العمليات الزائدة غير الضرورية.
  4. اختبار الوحدات:

    • قم بكتابة اختبارات للتأكد من أن وحدات الكود الخاصة بك تعمل كما هو متوقع.
  5. الأمان:

    • تحقق دائمًا من صحة البيانات الواردة والخارجة من الدوال.
    • تفادى استخدام الأكواد المعرضة لثغرات أمان.
  6. تحسين الأداء:

    • استخدم الهندسة العكسية لتحسين الأداء.
    • ابحث عن فرص لتحسين الكفاءة والسرعة.
  7. استخدام التعليمات البرمجية النظيفة:

    • ابتعد عن استخدام المتغيرات العالمية عندما لا تكون ضرورية.
    • تجنب الأكواد التي تعتمد على التبديلات الطويلة.
  8. توثيق الكود:

    • وفر توثيقًا جيدًا للكود ليسهل على المطورين الآخرين أو نفسك فهم كيف يعمل البرنامج.
  9. متابعة المعايير:

    • اتبع معايير البرمجة المتعارف عليها .
  10. التحسين المستمر:

    • كن مستعدًا لتحسين الكود الخاص بك بناءً على التعلم وتغييرات متطلبات المشروع.

الالتزام بتلك المبادئ يمكن أن يساعدك في كتابة كود أكثر احترافية وقابل للصيانة.

 

حلو الكلام وكل ده هيبان بقدر المستطاع فى التعليمات البرمجية التى سوف تتم تباعا

 يمكنك استخدام البادئات التالية لتسمية العناصر والكائنات بشكل منظم ويجعل الشيفرة أكثر وضوحًا.

البادئات تعتمد على النوع أو الدور الذي تقوم به العناصر:
 

وعلى سبيل المثال وليس الحصر

  1. المتغيرات:

    • int للأعداد الصحيحة.
    • dbl للأعداد العشرية.
    • str للنصوص.
    • bool للقيم البولية اى True , False أو Yes , No .
       
    Dim intCounter As Integer 
    Dim dblAmount As Double 
    Dim strName As String 
    Dim boolIsValid As Boolean
     
  2. المصفوفات:

    • arr للمصفوفات.
    Dim arrNames() As String
  3. الدوال:

    • Function للدوال التي تعيد قيمة.
    • Sub للإجراءات (دوال بدون إرجاع قيمة).
    Function CalculateTotal() As Double 
    Sub DisplayMessage()
  4. الكائنات:

    • frm للنماذج (Forms).
    • rpt للتقارير (Reports).
    • tbl للجداول (Tables).
    • qry للاستعلامات (Queries).
    • cls للكائنات أو الفئات لتعريف الكلاسات (Classes).
    • bas وحدات الشيفرة- الوحدات النمطية (Modules).
    • tbl للجداول (Tables).
    • qry للاستعلامات (Queries).
    Dim frmCustomer As Form 
    Dim rptSales As Report 
    Dim tblData As TableDef 
    Dim qryFilteredData As QueryDef
  5. الثوابت:

    • c للثوابت.
    Const cMaxValue As Integer = 100
  6. المتغيرات العامة:

    • g للمتغيرات العامة.
    Public gCounter As Integer
  7. المتغيرات المؤقتة:

    • temp للمتغيرات المؤقتة.
    Dim tempValue As Integer
  8. التعليقات:

    • REM لتعليقات الشيفرة.
    REM هذا تعليق لشرح الشيفرة
  • الأشكال والعناصر الرسومية:

  • btn للأزرار (Buttons).
  • lbl للتسميات (Labels).
  • txt لحقول النص (Textboxes).
  • chk لمربعات الاختيار (Checkboxes).

القوائم والمراقبين:

  • cmb لقائمة الاختيار (Comboboxes).
  • lst لقوائم الاختيار (Listboxes).
  • cb لمراقبات الصندوق (Checkboxes).

الكائنات الأخرى:

  • app لكائن التطبيق (Application).
  • cnn لكائن الاتصال (Connection).
  • doc لكائن المستند (Document).

الحقول والأعمدة:

  • fld لحقول البيانات (Fields).
  • col لعمود البيانات (Column).
 
 
 
  • Like 6
  • Thanks 11
رابط هذا التعليق
شارك

  • ابو جودي changed the title to تصميم قاعدة بيانات احترافيه لإدارة يوميات وشئون العاملين

البيانات الرئيسية والتى نريد تحضيرها مرة واحدة فقط عند بدء التطيق لنتمكن من استخدامها فى زوايا التطبيق المختلفة

على سبيل المثال وليس الحصر

نريد اسم الشركة دائما فى كل التقارير 

مثلا عند تحقق شرط معين بيانات الاتصال بالمصمم

لعمل ذلك نقوم ببناء جدول ليكون اسمه tblGlobalInformation

بناء الجدول يعتمد على حقلين itemName ,  itemValue

والان وحدة نمطية جديدة ليكون اسمها = basGlobalInformation

فى الوحدة النمطية نقوم بعمل Enumeration

هي كلاسات خاصة تستخدم لتعريف ثوابت محددة مسبقا وتستخدم لتخزين عناصر متتالية دفعة واحدة بعدها يمكنه إرجاع هذه العناصر واحدا تلو الآخر حسب الحاجة

الاكواد داخل الوحدة النمطية basGlobalInformation

Option Compare Database
Option Explicit

' Enumeration defining global information indices
Public Enum EnumInformation
    EnumStartIndex
    ' Enumeration values for global information start
    infSoftwarName
    infSoftwarVersion
    infDesignCompany
    infDesigerName
    infDesigerMail
    infDesigerPhone
    infCompanyName
    infCompanyGM
    EnumEndIndex = infCompanyGM
    ' Enumeration value for global information end
End Enum

' Array to store global information values
Public Ginf() As String

' Public variables to store individual global information values
Public GetSoftwarName As String
Public GetSoftwarVersion As String
Public GetDesignCompany As String
Public GetDesigerName As String
Public GetDesigerMail As String
Public GetDesigerPhone As String
Public GetCompanyName As String
Public GetCompanyGM As String

' The name of the table Global Information
Public Const TableGlobalInformationName As String = "tblGlobalInformation"

Function IsArrayInitialized(arr As Variant) As Boolean
    ' Check if the array is initialized (not empty or uninitialized)
    On Error Resume Next
    IsArrayInitialized = (UBound(arr) >= LBound(arr))
    On Error GoTo 0
End Function

Public Sub SetGlobalVariables()
    ' Procedure to set global variables based on database values
    On Error Resume Next
    
    ' Open a recordset based on the SQL query
    Dim db As DAO.Database
    Dim rs As DAO.Recordset
    Dim strSQL As String
    
    Set db = CurrentDb
    
    ' Check if the table exists in the database
    If Not IsTableExists(TableGlobalInformationName, db) Then Exit Sub
    
    ' Check if global information values are already populated
    If Not IsArrayInitialized(Ginf) Then
        ' Resize the global information values array based on the count of enumeration items
        ReDim Ginf(1 To EnumEndIndex - EnumStartIndex) As String

        ' Create a SQL query to retrieve all required items in one go
        strSQL = "SELECT itemName, itemValue FROM " & TableGlobalInformationName & " WHERE itemName " & _
                 "IN ('SoftwarName', 'SoftwarVersion', 'DesignCompany', 'DesigerName', " & _
                 "'DesigerMail', 'DesigerPhone', 'CompanyName', 'CompanyGM');"

        ' Open a recordset based on the SQL query
        Set rs = db.OpenRecordset(strSQL)

        ' Loop through the recordset and assign values to global information values array
        Do While Not rs.EOF
            Dim itemName As String
            itemName = rs.Fields("itemName").Value
            Dim itemIndex As Integer
            itemIndex = GetInfoIndex(itemName)

            If itemIndex <> -1 Then
                Ginf(itemIndex) = rs.Fields("itemValue").Value
            Else
                Debug.Print "ItemName: " & itemName & " not found in EnumInf."
            End If

            rs.MoveNext
        Loop
        
        ' Assign individual global information values to public variables
        GetSoftwarName = Ginf(EnumInformation.infSoftwarName)
        GetSoftwarVersion = Ginf(EnumInformation.infSoftwarVersion)
        GetDesignCompany = Ginf(EnumInformation.infDesignCompany)
        GetDesigerName = Ginf(EnumInformation.infDesigerName)
        GetDesigerMail = Ginf(EnumInformation.infDesigerMail)
        GetDesigerPhone = Ginf(EnumInformation.infDesigerPhone)
        GetCompanyName = Ginf(EnumInformation.infCompanyName)
        GetCompanyGM = Ginf(EnumInformation.infCompanyGM)
        
        ' Close the recordset
        rs.Close
        Set rs = Nothing
    End If
    
    ' Handle errors
    If Err.Number <> 0 Then
        ' Handle error

        If Err.Number = 94 Then Exit Sub

        ' Handle the error (display a message)
        Call ErrorLog(Err, Error$, "basEnumInformationrmation : SetGlobalVariables")

        Err.Clear
    End If

    On Error GoTo 0

End Sub

Function GetInfoIndex(itemName As String) As Integer
    ' Helper function to get the index of an item in the EnumInformation enumeration
    Select Case itemName
        Case "SoftwarName"
            GetInfoIndex = EnumInformation.infSoftwarName
        Case "SoftwarVersion"
            GetInfoIndex = EnumInformation.infSoftwarVersion
        Case "DesignCompany"
            GetInfoIndex = EnumInformation.infDesignCompany
        Case "DesigerName"
            GetInfoIndex = EnumInformation.infDesigerName
        Case "DesigerMail"
            GetInfoIndex = EnumInformation.infDesigerMail
        Case "DesigerPhone"
            GetInfoIndex = EnumInformation.infDesigerPhone
        Case "CompanyName"
            GetInfoIndex = EnumInformation.infCompanyName
        Case "CompanyGM"
            GetInfoIndex = EnumInformation.infCompanyGM
    End Select
End Function

 

طيب بما اننا نتكلم عن اعدادات مهمة لابد من تحقيقها عند بدء التطبيق سوف نقوم بعمل وحدة نمطية باسم basInitialization
ونضع بها الاكواد الاتية
 

Rem Subroutine to initialize the application
Sub InitializeApplication()
    
    Rem Initialize the error log table if it doesn't exist
    If Not IsErrorLogTableInitialized() Then CreateErrorLogTable
    
    Rem Call the function to set global variables.
    SetGlobalVariables

End Sub

ونقوم بعمل نموذج البدء ليكون اسمه frmInitialization

فى هذا النموذج نستدعى الدالة السابقة فى حدث عند تحميل النموذج بالشكل التالى 

Private Sub Form_Load()
    On Error Resume Next
    
    Rem Set the initial time as the interval for the timer
        
    Rem Initialize the application when the startup form is loaded.
    InitializeApplication
       
    
    Rem Add calls to the initialized special functions through which you want the database to be booted
    Rem Or add specify the codes through which you would like to process the data later according to the requirements of your design

    Rem Set the current procedure name (you can adjust the procedure name as needed)
    If Err.Number <> 0 Then
    
        Rem Clear the error
        Err.Clear
    End If
End Sub

 

يتبع ...

واخيرا المرفق 

 

 

HRManagement V 1.0.0.accdb

  • Like 2
  • Thanks 1
  • Confused 1
رابط هذا التعليق
شارك

لتصميم الشاشة الرئيسية وسهولة التحكم فىيها 

تم اضافة جدول جديد باسم tblFormsTitle

يتكون من الحقول 

  •  FormName  = اسم النموذج الفرعى
  • FormDesc    = وصف النموذج ( معيار احضار بيانات اسم النموذج والعنوان فى الكود)
  • TitleForm     = العنوان فى الشاشة الرئيسية

البيانات داخل الجدول كالاتى 

اسم النموذج الفرعى    وصف النموذج ( معيار احضار بيانات اسم النموذج والعنوان فى الكود)        العنوان فى الشاشة الرئيسية   
frmHomeMenu HomeMenu الرئيسية
frmSub1ImportOraclExcel ImportExcel استيراد بيانات الحضور والانصراف ( Oracle's Excel sheet )         
frmSub2DailyEmployee DailyEmployee ادارة يوميات الموظفين ( اضافة / تعديل / حذف )
frmSub3QueryDaily QueryDailyBy استعلام وتقارير يوميات الموظفين
frmSub4Employees EmployeesData ادارة بيانات الموظفين ( اضافة / تعديل / حذف )
frmSub5DailyLogsType DailyLogsType ادارة انواع اليوميات ( اضافة / تعديل / حذف )
frmSub6Department Department ادارة بيانات الادارات و المديرين ( اضافة / تعديل / حذف )
frmSub7Section Section ادارة بيانات الاقسام ( اضافة / تعديل / حذف )

 تم تصميم النماذج الفرعية بدون اى مصدر بيانات .... 

عمل نموذج رئيسي باسم frmMain

فى وضع التصميم تم اضافة نموذج فرعى غير  منضم باسم subformControl

تم اضافة مربع تسمية ( Lable ) باسم lblTitle

اضافة عدد سبع ازرار باسماء   btnNavItem1 ,btnNavItem2 , btnNavItem3 , ........ الخ

عنصر تحكم صورة باسم imgArrow يحتوى على شكل سهم 

الاكواد فى النموذج 

قائمة بوظائف الازرار تبعا لوصف النماذج من الجدول والذى اشرنا الى الحقل الخاص به وصف النموذج ( معيار احضار بيانات اسم النموذج والعنوان فى الكود)

' Enum to define button actions
Enum ButtonAction
    HomeMenu
    ImportExcel
    DailyEmployee
    QueryDailyBy
    EmployeesData
    DailyLogsType
    Department
    Section
End Enum


متغيرات لاسناد قيم اليها

' Declare variables to store form name and title
Private strFormName As String
Private strTitleForm As String
Private subformInfoArray As Variant

 

دالة لتحديد المعيار لجلب البيانات للنماذج الفرعية من الجدول  ( اسم النموذج - العنوان فى الشاشة الرئيسية ) بناء على Enum  قائمة الازرار

' Sub to handle button click events
Private Sub HandleButtonClick(btnAction As ButtonAction)
    Dim subformInfoResult As String
    
    ' Get subform information based on the button action
    subformInfoResult = GetSubformInfo(ButtonActionToString(btnAction))
    
    ' Process the subform information and update the form
    ProcessSubformInfo subformInfoResult
End Sub

 

دالة لاحضار معلومات النماذج الفرعية من الجدول  ( اسم النموذج - العنوان فى الشاشة الرئيسيةبناء على المعيار من الدالة السابقة

' Function to get the name and title of the subform based on the form description
Function GetSubformInfo(subformDesc As String) As String
    ' Use On Error Resume Next to handle errors gracefully
    On Error Resume Next

    ' Declare a DAO Recordset variable
    Dim rs As DAO.Recordset

    ' Open a recordset based on the provided form description
    Set rs = CurrentDb.OpenRecordset("SELECT FormName, TitleForm FROM tblFormsTitle WHERE FormDesc='" & subformDesc & "'")

    ' Check if the recordset is not empty
    If Not rs.EOF Then
        ' Return the concatenated string of FormName and TitleForm
        GetSubformInfo = rs!formName & "," & rs!titleForm
    Else
        ' Return an empty string if no matching record is found
        GetSubformInfo = ""
    End If

    ' Close the recordset to free up resources
    rs.Close
    Set rs = Nothing

    ' Check for errors and display debug information
    If Err.Number <> 0 Then
        MsgBox "Error retrieving subform information: " & Err.Description, vbExclamation
        Err.Clear
    End If
End Function

دالة لفصل اسم النموذج والعنوان والذى تم الحصول عليهم من الدالة السابقة

' Sub to process subform information and update the form
Sub ProcessSubformInfo(subformInfoResult As String)
    ' Split the subformInfo into an array
    subformInfoArray = Split(subformInfoResult, ",")
    
    ' Extract the formName and title from the array
    If UBound(subformInfoArray) >= 1 Then
        strFormName = Trim(subformInfoArray(0))
        strTitleForm = subformInfoArray(1)
    End If
    
    ' Update the form based on the subform information
    UpdateFormBasedOnSubformInfo
End Sub

 

دالة للتحكم فى اظهار واخفاء موضع صورة سهم تدل على النموذج الفرعى تبعا لزر الامر 
 

' Sub to move the arrow indicator on the form
Sub MoveArrow()
    ' Make the arrow visible and position it below the active control
    If Not Me.imgArrow.Visible Then Me.imgArrow.Visible = True
    Me.imgArrow.Top = Me.ActiveControl.Top
    ChangeCommandButtonColor Me
End Sub

 

دالة تحديث النموذج بناء على المعطيات السابقة من الدوال بمجرد النقر على زر الامر 
 

' Sub to update the form based on the subform information
Sub UpdateFormBasedOnSubformInfo()
    Select Case Nz(strFormName, "frmHomeMenu")
        Case Is = "frmHomeMenu"
            Me.lblTitle.Caption = strTitleForm
            subformControl.Visible = False
            ChangeCommandButtonColor Me, False
            Me.imgArrow.Visible = False
            Me.subformControl.SourceObject = ""
            Me.subformControl.Height = 0
        Case Else
            Me.lblTitle.Caption = strTitleForm
            MoveArrow
            ChangeCommandButtonColor Me
            Me.subformControl.Height = BoxMain.Height
            Me.subformControl.SourceObject = strFormName
            subformControl.Visible = True
    End Select
End Sub

الاكواد لضبط وتحديد الحدث المراد تنفيذه تبعا لازرار الاوامر 

' Function to convert ButtonAction to corresponding form description
Function ButtonActionToString(btnAction As ButtonAction) As String
    Select Case btnAction
        Case ButtonAction.HomeMenu: ButtonActionToString = "HomeMenu"
        Case ButtonAction.ImportExcel: ButtonActionToString = "ImportExcel"
        Case ButtonAction.DailyEmployee: ButtonActionToString = "DailyEmployee"
        Case ButtonAction.QueryDailyBy: ButtonActionToString = "QueryDailyBy"
        Case ButtonAction.EmployeesData: ButtonActionToString = "EmployeesData"
        Case ButtonAction.DailyLogsType: ButtonActionToString = "DailyLogsType"
        Case ButtonAction.Department: ButtonActionToString = "Department"
        Case ButtonAction.Section: ButtonActionToString = "Section"
    End Select
End Function

 

الاكواد على ازرار الاوامر 


Private Sub ImageLogo_Click()
    HandleButtonClick HomeMenu
End Sub

Private Sub btnNavItem1_Click()
    HandleButtonClick ImportExcel
End Sub

Private Sub btnNavItem2_Click()
    HandleButtonClick DailyEmployee
End Sub

Private Sub btnNavItem3_Click()
    HandleButtonClick QueryDailyBy
End Sub

Private Sub btnNavItem4_Click()
    HandleButtonClick EmployeesData
End Sub

Private Sub btnNavItem5_Click()
    HandleButtonClick DailyLogsType
End Sub

Private Sub btnNavItem6_Click()
    HandleButtonClick Department
End Sub

Private Sub btnNavItem7_Click()
    HandleButtonClick Section
End Sub


واخيرا وحدة نمطية باسم basChangeButtonColor

خاصة بتغير لون زر الامر الذى يتم الضغط عليه فى النموذج الرئيسى

' Enum for colors
Enum ColorEnum
    WhiteColor = 16777215 ' White
    RedColor = 255 ' Red
    GreenColor = 32768 ' Green
    BlueColor = 16711680 ' Blue
    PurpleColor = 8388736 ' Purple
    GrayColor = 8421504 ' Gray
    OrangeColor = 16753920 ' Orange
    BrownColor = 10824234 ' Brown
    BlackColor = 0 ' Black
    CyanColor = 16776960 ' Cyan
    MagentaColor = 16711935 ' Magenta
    YellowColor = 65535 ' Yellow
    LightBlueColor = 173216230 ' Light Blue
    DarkGreenColor = 65280 ' Dark Green
    PinkColor = 16761035 ' Pink
    LavenderColor = 230230250 ' Lavender
    OliveColor = 32896 ' Olive
    AquaColor = 65535 ' Aqua
    TurquoiseColor = 4251856 ' Turquoise
    GoldColor = 16766720 ' Gold
    SilverColor = 12632256 ' Silver
    MaroonColor = 8388608 ' Maroon
    NavyColor = 128 ' Navy
    TealColor = 8421376 ' Teal
    CoralColor = 5275647 ' Coral
    SalmonColor = 16416882 ' Salmon
    IndigoColor = 4915330 ' Indigo
    PeachColor = 16775640 ' Peach
    SiennaColor = 10506797 ' Sienna
    SkyBlueColor = 8900331 ' Sky Blue
End Enum


' Module-level variables
Dim currentButtonBackColor As Long   ' Variable to store the current button back color
Dim currentButtonForeColor As Long   ' Variable to store the current button fore color
Dim selectedButton As CommandButton  ' Variable to store the selected button

' Subroutine to set the button color
Sub SetButtonColor(ByVal frm As Form, Optional btn As CommandButton = Nothing)
    ' Set new button colors
    Dim newButtonBackColor As Long
    Dim newButtonForeColor As Long
    
    newButtonBackColor = ColorEnum.GrayColor
    newButtonForeColor = ColorEnum.BlackColor
    
    If Not btn Is Nothing Then
        ' Store the current button's colors
        currentButtonBackColor = btn.BackColor
        currentButtonForeColor = btn.ForeColor

        ' Clear the previous button's highlight
        If Not selectedButton Is Nothing Then
            selectedButton.BackColor = currentButtonBackColor
            selectedButton.ForeColor = currentButtonForeColor
        End If

        ' Set the new button as selected and highlight it
        Set selectedButton = btn
        btn.BackColor = newButtonBackColor
        btn.ForeColor = newButtonForeColor
    End If
End Sub

' Subroutine to change the button color
Sub ChangeCommandButtonColor(frm As Form, Optional changeColor As Boolean = True)
    On Error GoTo ErrorHandler

    Dim clickedButton As CommandButton
    Set clickedButton = frm.ActiveControl

    ' Store the default button colors before changing
    Dim currentButtonBackColor As Long
    Dim currentButtonForeColor As Long
    
    currentButtonBackColor = clickedButton.BackColor
    currentButtonForeColor = clickedButton.ForeColor

    ' Clear the previous button's highlight
    If Not selectedButton Is Nothing Then
        selectedButton.BackColor = currentButtonBackColor
        selectedButton.ForeColor = currentButtonForeColor
    End If

    ' Set the new button as selected and highlight it
    Set selectedButton = clickedButton

    ' Apply the button color if changeColor is True
    If changeColor Then
        SetButtonColor frm, clickedButton
    End If
    
    Err.Clear ' Clear Err
    Exit Sub ' Exit to avoid handler.

ErrorHandler: ' Error-handling routine.
    Select Case Err.Number ' Evaluate error number.
        Case Is = 5
            Resume Next
            Exit Sub ' Exit to avoid handler.
        Case Else
            ' Handle other situations here...
            MsgBox "Error: " & Err.Number & vbCrLf & "Description: " & Err.Description
            Resume ' Resume execution at the same line
    End Select
End Sub

المميزات

1- عند الابتعاد عن الشاشة والعودة مرة أخرى بمجرد النظر يمكنك معرفة الزر الاخير الذى تم الضغط عليه 

2-سهولة تغيير العناوين التى تظهر على الشاشة الرئيسية تبعا لكل نموذج فرعى بكل سهولة بدون داعى للدخول الى عرض التصميم من الجدول :yes:

 

اختبار تجربة

01.thumb.gif.f38a982987e48604fee1e550c028ade2.gif

 

يتبع ...

واخيرا المرفق

 

 

 

HRManagement V 1.0.2.zip

  • Like 3
  • Thanks 2
رابط هذا التعليق
شارك

  • 4 weeks later...
زائر
هذا الموضوع مغلق.
×
×
  • اضف...

Important Information