ورود

View Full Version : سوال: مشکل در جستجوی برنامه



Mr.Unknown
یک شنبه 08 خرداد 1390, 16:53 عصر
سلام دوستان

یه مشکل بزرگی توی برنامم هست که نتونستم درستش کنم از دوستان می خوام راهنمایی کنن

بنده توی برنامه جستجوی پیشرفته گذاشتم با کدهای زیر
StrSql = " Where Statue='False' "
If State1 <> "" And AllStates = False Then
StrSql = StrSql + " And PlaceO='" & State1 & "' "
End If
If State2 <> "" And AllStates = False Then
'StrSql = StrSql + " or PlaceO='" & State2 & "' "
'End If
If State3 <> "" And AllFarei = False Then
'StrSql = StrSql + " And PlaceF='" & State3 & "' "
'End If
If State4 <> "" And AllFarei = False Then
'StrSql = StrSql + " Or PlaceF='" & State4 & "' "
'End If
If ZirBana <> "0" Then
StrSql = StrSql + " And Zirbana='" & ZirBana & "' "
End If
If Metraj <> "0" And Metraj2 <> "0" Then
StrSql = StrSql + " And Metraj>='" & Metraj & "' And Metraj<='" & Metraj2 & "' "
End If
If BarZamin <> "0" And BarZamin2 <> "0" Then
StrSql = StrSql + " And BarZamin>='" & BarZamin & "' And BarZamin<='" & BarZamin2 & "' "
End If
If Bed <> "0" And Bed2 <> "0" Then
StrSql = StrSql + " And Bed>='" & Bed & "' And Bed<='" & Bed2 & "' "
End If
If Age <> "0" And Age2 <> "0" Then
StrSql = StrSql + " And Age>='" & Age & "' And Age<='" & Age2 & "' "
End If
If Price <> "0" And PricePre <> "" And Price2 <> "0" And PricePre2 <> "" Then
StrSql = StrSql + " And P2>='" & Price & "' And PricePre='" & PricePre & "' And P2<='" & Price2 & "' "
End If
If Rahn <> "0" And RahnPre <> "" And Rahn2 <> "0" And RahnPre2 <> "" Then
StrSql = StrSql + " And Ra2>='" & Rahn & "' And RahnPre='" & RahnPre & "' And Ra2<='" & Rahn2 & "' "
End If
If Rent <> "0" And RentPre <> "" And Rent2 <> "0" And RentPre2 <> "" Then
StrSql = StrSql + " And R2>='" & Rent & "' And RentPre='" & RentPre & "' And R2<='" & Rent2 & "' "
End If

If Tarakom <> "" Then
StrSql = StrSql + " And Tarakom='" & Tarakom & "' "
End If
If DocumentType <> "" Then
StrSql = StrSql + " And DocumentType='" & DocumentType & "' "
End If


منتها وقتی از شرط or استفا ده میکنم دیگه بر اساس بقیه شرطا (And)فیلتر نمیکنه فقط به این 2 شرط رسیدگی میکنه
If State2 <> "" And AllStates = False Then
StrSql = StrSql + " or PlaceO='" & State2 & "' "
End If

If State4 <> "" And AllFarei = False Then
StrSql = StrSql + " Or PlaceF='" & State4 & "' "
End If
لطفا سریعا راهنمایی کنید

NitroPlus
سه شنبه 10 خرداد 1390, 08:35 صبح
برنامه شما چی هست و چه کار می کنه؟

vbhamed
سه شنبه 10 خرداد 1390, 19:36 عصر
سلام

شما بايد همه شرطهاي And رو با هم درون يك پرانتز و همه شرطهاي Or رو هم با هم درون يك پرانتر ديگه بزاريد و بين اين دو پرانتز از And استفاده كنيد

مثال

( c1 And c2 And c1 And c4 ) And ( c5 Or c6 Or c7 )