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

سؤال بخصوص ضبط الـمعيار برمجيا ليقبل التعامل مع حقول نصية


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

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

الكود يعمل بشكل ممتاز مع الحقول الرقمية
ممكن التفضل والتكرم بضبط الكود كى يعمل الكود مع الحقول النصيه كما هو الحال مع الحقول الرقمية

search _01.rar

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

النموذج المطلوب التعديل عليه هو           frm_Search

وتم التنويه على النموذج بالمطلوب للايضاح اكثر ان شاء الله

search _02.rar

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

تم حل المشكلة وتم ضبط الكود بفضل الله تعالى 
وهذه هى النتيجه حتى تعم الفائده

search _ done.rar

تم تغير هذا السطر فى الكود
 

strTag = ctl.Tag

بهذا الكود
 

strTag = """"

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

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

و هذا حل آخر

For Each ctl In Me.Controls
        If ctl.ControlType = acTextBox Or ctl.ControlType = acCheckBox Then
            If Not IsNull(ctl.Value) Then
               If IsNumeric(ctl.Value) Then
                  strWhere = strWhere & " AND " & ctl.Name & " = " & ctl.Value      
               Else
                  strWhere = strWhere & " AND " & ctl.Name & " like " & "'" & ctl.Value & "'"
               End If
            End If
        End If
Next

و هذا هو المرفق

search _02.rar

تم تعديل بواسطه صالح حمادي
  • Like 2
رابط هذا التعليق
شارك

10 دقائق مضت, صالح حمادي said:

و هذا حل آخر


For Each ctl In Me.Controls
        If ctl.ControlType = acTextBox Or ctl.ControlType = acCheckBox Then
            If Not IsNull(ctl.Value) Then
                strTag = ctl.Tag
               If IsNumeric(ctl.Value) Then
               strWhere = strWhere & " AND " & ctl.Name & " = " & ctl.Value
                         
               Else
                strWhere = strWhere & " AND " & ctl.Name & " like " & "'" & ctl.Value & "'"
               End If
            
            End If
        End If
    Next

و هذا هو المرفق

search _02.rar

جزاكم الله كل الخير :fff:

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

5 ساعات مضت, صالح حمادي said:

و هذا حل آخر


For Each ctl In Me.Controls
        If ctl.ControlType = acTextBox Or ctl.ControlType = acCheckBox Then
            If Not IsNull(ctl.Value) Then
               If IsNumeric(ctl.Value) Then
                  strWhere = strWhere & " AND " & ctl.Name & " = " & ctl.Value      
               Else
                  strWhere = strWhere & " AND " & ctl.Name & " like " & "'" & ctl.Value & "'"
               End If
            End If
        End If
Next

و هذا هو المرفق

search _02.rar

هل يمكن اختصاص حقل محدد للبحث بجزء من الكلمه ؟

 

اقصد طبعا احد الحقول النصيه

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

24 دقائق مضت, ابا جودى said:

هل يمكن اختصاص حقل محدد للبحث بجزء من الكلمه ؟

 

اقصد طبعا احد الحقول النصيه

فقط غير هذا السطر

                  strWhere = strWhere & " AND " & ctl.Name & " like " & "'" & ctl.Value & "'"

بهذا

                    strWhere = strWhere & " AND " & ctl.Name & " like " & "'" & "*" & ctl.Value & "*" & "'"

وهذا المرفق
تحياتي

search _02.rar

تم تعديل بواسطه Shivan Rekany
  • Like 3
رابط هذا التعليق
شارك

14 دقائق مضت, Shivan Rekany said:

فقط غير هذا السطر


                  strWhere = strWhere & " AND " & ctl.Name & " like " & "'" & ctl.Value & "'"

بهذا


                    strWhere = strWhere & " AND " & ctl.Name & " like " & "'" & "*" & ctl.Value & "*" & "'"

وهذا المرفق
تحياتي

search _02.rar

شكرا اخي الحبيب واستاذي القدير

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

اعتذر انا فاتح من الجوال بس اروح وان شاء الله اجرب المرفق فورا

 

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

مشاركة مع اخوتي واحبتي

افضل عملية بحث احتفظ بها (طريقة استاذنا جعفر )

Dim mySQL As String
 Dim mySQL1 As String
Private Sub Form_Load()

    mySQL = "Select * From tbl_test"
    Me.ID = ""
    If Len(Me.ID & "") = 0 Then
        Me.sfmList.Form.RecordSource = mySQL
    End If
End Sub

Private Sub ID_Change()
    Dim fld As String
    Dim x() As String
    Dim A As String
    Dim i
    fld = "ID"
    fld = fld & " & ' ' & " & "fname"
    fld = fld & " & ' ' & " & "mname"
    fld = fld & " & ' ' & " & "lname"
    mySQL1 = "Select * From tbl_test"
    mySQL = mySQL1 & " Where "
    Me.ID.SetFocus
    A = Me.ID.Text
    A = Replace(A, "/", "|")
    A = Replace(A, "\", "|")
    A = Replace(A, " ", "|")
    A = Replace(A, "*", "|")
    x = Split(A, "|")
    If UBound(x) = 0 Then
        mySQL = mySQL & fld
          mySQL = mySQL & " Like '*" & x(i) & "*'"
      Else
         For i = LBound(x) To UBound(x)
            If i = 0 Then
                mySQL = mySQL & fld
                  mySQL = mySQL & " Like '*" & x(i) & "*'"
            Else
                mySQL = mySQL & " AND " & fld
                  mySQL = mySQL & " Like '*" & x(i) & "*'"
            End If
         Next i
    End If
     If Len(Me.ID.Text & "") = 0 Then
        mySQL = mySQL1
    End If
    Me.sfmList.Form.RecordSource = mySQL
End Sub

 

افضل عملية بحث.rar

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

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