Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Search/Filtering

Status
Not open for further replies.
Oct 28, 2003
50
MY
Hi........I have this code under my FIND button. It works fine. Then just now I refresh the data in my link tables. After that this code does not work as it suppose to.....
This is the code:

Private Sub btnFind_Click()
On Error Resume Next

Dim ssql As String
Dim scriteria As String
scriteria = "WHERE 1=1 "


If Me![txtJobNo] <> &quot;&quot; Then
scriteria = scriteria & &quot; AND QryUpdateRevise.GBMCU like &quot;&quot;&quot; & txtJobNo & &quot;&quot;&quot;&quot;
End If

If Me![txtType] <> &quot;&quot; Then
scriteria = scriteria & &quot; AND QryUpdateRevise.TYPE like &quot;&quot;&quot; & txtType & &quot;&quot;&quot;&quot;
End If

ssql = &quot;SELECT [JOBNO], [TYPE], [OBJECT], [SUBJOB], [ID], [AMT], [DESC], [REVISE] from QryUpdateRevise &quot; & scriteria
Me.Form.RecordSource = ssql
Me.Requery

End Sub

As u see in my codes....I have 2 criteria set for records search...
-> to search base on Job No selected by the user in txtJobNo text box AND base on the Type also selected by user in txtType text box.

This search function works OK for Job No but for searching that according to type (there are 2 types that exist TYPE-A and TYPE-U)....when the user select TYPE-U.....the search function works fine (my system will only display data with TYPE-U) but when the user select TYPE-A.....the search function didn't do it 's job........because my system will display the data for both types...that is TYPE-A and TYPE-U........

I really can't figure out...what is wrong with my codes....
Please help
 
C,

do a MSGBOX ssql and you will see that you are not sending what you want to send to the compiler. You need some ticks (') and you need some concatenation of strings like ---


SQL = &quot;SELECT * from 'Mytable' where [MyID] = '&quot; & MyName1 & &quot;';&quot;


rollie@bwsys.net
 
MsgBox is a built in function that shows the value of any variable.

Thus if msgbox me.text0 were under a command button, whenever you pressed the button it would tellyou the value in the form control named text0

Rollie
 
Thanks Rolliee......u really help things out.....

using the &quot;msgbox me.text0 &quot; I found out that my query contains the wrong data.....after I change the query my Search/filtering function works fine........

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top