I have a search form for a database that has the user fill in the different fields to get their search criteria. If the fields have data in them they are added into a search string that is then executed and the results are put into a folder “Query Report”. A portion of the code looks like this:
SearchFormula$ = |Form = “RP”| + " | " + |Form = “RPLegacy”|
If (doc.site(0) <> “”) Then SearchFormula$ = SearchFormula$ + " & " + “Site = @Text('” + doc.site(0) +“')”
If (doc.manufacturer(0) <> “”) Then SearchFormula$ = SearchFormula$ + " & " + “@Contains(@ProperCase(Manufacturer);”+“@ProperCase('”+doc.Manufacturer(0)+“')”+“)”
If (doc.Product_Name(0) <> “”) Then SearchFormula$ = SearchFormula$ + " & " + “@Contains(@ProperCase(Product_Name);”+“@ProperCase('”+doc.Product_Name(0)+“')”+“)”
If (doc.Synonym(0) <> “”) Then SearchFormula$ = SearchFormula$ + " & " + “@Contains(@ProperCase(Synonym);”+“@ProperCase('”+doc.Synonym(0)+“')”+“)”
If (doc.MSDS_No(0) <> “”) Then SearchFormula$ = SearchFormula$ + " & " + “@Contains(@ProperCase(MSDS_No);”+“@ProperCase('”+doc.MSDS_No(0)+“')”+“)”
If (doc.Stock_Code(0) <> “”) Then SearchFormula$ = SearchFormula$ + " & " +“@Contains(@ProperCase(Stock_Code);”+“@ProperCase('”+doc.Stock_Code(0)+“')”+“)”
If (doc.Product_Group(0) <> “”) Then SearchFormula$ = SearchFormula$ + " & " + “@Contains(@ProperCase(Product_Group);”+“@ProperCase('”+doc.Product_Group(0)+“')”+“)”
Set collection = db.Search(SearchFormula$, dt, 0)
Call collection.PutAllInFolder( “Query Report” )
Call fview.Refresh
Call workspace.ViewRefresh
Call uidoc.Close
The code works great and I can obtain successful searches on all fields EXCEPT for the Stock_Code field. When a value is entered into that field I always come up with an empty search even though I know the documents exist. The field Stock_Code is a text list field in my forms “RP” and “RPLegacy”. It is also a text field in my search form called “Stock_Code”.
If I search for a paticular document I can find it using any of the other fields but if i put in the Stock_Code it will not find the document.
I have run the code through the debugger and it appears that it is grabbing the values correctly however it will not return any documents when i put in a Stock_Code
Why does this code work for all my other fields fine but not for this field?
**NOTE: I did not write this code originally but I maintain the database now. A user has asked me why the Stock_Code field is not being searched on correctly, and have claimed it had never worked.