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

افيدوني في تعديل كود


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

السلام عليكم ورحمه الله

تحية طيبة وبعد

اشكر الاستاذ : جعفر ................. على مجهودة العظيم 

عندي نموذج وفية حقلين : عن التاريخ

اريد ابحث بين الحقلين : "من تاريخ" & "الى تاريخ "   .... وتعديل الكود على التاريخ 

بحيث يبحث : من تاريخ & الى تاريخ

وهذا الكود , والمرفق ......بارك الله فيكم

 

Private Sub n2_Change()

    'do the initial subform Record Source
    mySQL1 = "Select * From [المستندات]"
    mySQL = mySQL1 & " Where"
    
    'now we want to split the search code into smaller bits,
    'if seperate by / \ * or space, then change this seperator to | (a unique letter),
    'this way we will have more than ONE word to search for
    Dim x() As String
    Dim A As String
    
    A = Me.n2.Text
    A = Replace(A, "/", "|")
    A = Replace(A, "\", "|")
    A = Replace(A, " ", "|")
    A = Replace(A, "*", "|")
    
    'the words are split and ready
    x = Split(A, "|")
    
    If UBound(x) = 0 Then
        'Still one word, search for it
        mySQL = mySQL & " [كلمات ارشادية]"
        mySQL = mySQL & " Like '*" & x(i) & "*'"
    
    Else
        'it is ONE word and a seperate by / \ * or space,
        'so lets make a Where statement for each seperate word
        For i = LBound(x) To UBound(x)
        
            If i = 0 Then
                'its a word and a seperator, the NEXT word is NOT added yet
                mySQL = mySQL & " [كلمات ارشادية]"
                mySQL = mySQL & " Like '*" & x(i) & "*'"
            Else
                'its multiple words, add the AND command between each word
                mySQL = mySQL & " AND [كلمات ارشادية]"
                mySQL = mySQL & " Like '*" & x(i) & "*'"
            End If
            
        Next i
    End If
    
    'if the Search field is Empty, use the initial mySQL1
    Me.n2.SetFocus
    If Len(Me.n2.Text & "") = 0 Then
        mySQL = mySQL1
    End If
    
    'Debug.Print mySQL
    Me.sfrm_Search.Form.RecordSource = mySQL
    
    
End Sub

ok ok ok.rar

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

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