اذهب الي المحتوي
أوفيسنا
بحث مخصص من جوجل فى أوفيسنا
Custom Search

تجاهل زر اغلاق عند وجود خلايا فارفة


Akram Galal

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

السادة الأفاضل أعضاء المنتدى
كل عام وأنتم بخير
أريد كود يقوم بالأتي

عند الضغط علي زر × مع وجود خلية معينة فارغة تظهر رسالة "برجاء اكمال البيانات"

ويتم الغاء المر الإغلاق والعودة للفورم بدون مسح البيانات الموجوده بها

جزاكم الله خيرا .

رابط هذا التعليق
شارك

وعليكم السلام:smile:

 

1. يجب تعطيل X النموذج من اعدادات النموذج ،

2. عمل زر لإغلاق النموذج ،

3. استعمال هذا الكود:

كود زر اغلاق النموذج
Private Sub cmd_close_Click()

    Call Form_BeforeUpdate(False)
End Sub

Private Sub Form_BeforeUpdate(Cancel As Integer)
On Error GoTo err_Form_BeforeUpdate

    Dim ctl As Control
    
    For Each ctl In Me.Controls

        If ctl.ControlType = acTextBox Or _
           ctl.ControlType = acOptionGroup Or _
           ctl.ControlType = acComboBox Or _
           ctl.ControlType = acListBox Then
           
            If Len(ctl.Value & "") = 0 Then
                MsgBox "رجاء ادخال بيانات في الحقل " & vbCrLf & ctl.Name
                ctl.SetFocus
                Exit Sub
            End If  'Len
        
        End If  'ctl
    Next
    

    DoCmd.Close
    
Exit_Form_BeforeUpdate:
Exit Sub
err_Form_BeforeUpdate:

    If Err.Number = 2501 Then
        Resume Exit_Form_BeforeUpdate
    Else
        MsgBox Err.Number & vbCrLf & Err.Description
    End If
    
End Sub

 

جعفر

رابط هذا التعليق
شارك

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

زائر
اضف رد علي هذا الموضوع....

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • تصفح هذا الموضوع مؤخراً   0 اعضاء متواجدين الان

    • لايوجد اعضاء مسجلون يتصفحون هذه الصفحه
×
×
  • اضف...

Important Information