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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to look for integers?

Status
Not open for further replies.

jumpjack

Programmer
Jul 28, 2006
79
IT
Why does this VB line returns a value if CAMPO is the name of a field and VALORE is a possible valule for that field, but it returns "0" if CAMPO is the name of another field, and VALORE is a possible value for this other field?

Set GlobalCollection = db.SEARCH("@Contains(" & CAMPO & ";" & VALORE & ")", dateTime, 0)

I knwo that in both cases SEARCH should return values different from zero, as I SAW the documents it should count... so why doesn't it count them?
The only difference between CAMPO1 and CAMPO2 is that first can have string values, second can have integer values: should I use a different function to look for integers?

-- Jumpjack --
 
I do believe that the Search function can only search text.

Another possible issue could be that your database is not Full Text indexed, which hampers the Search functionality.

Pascal.


I've got nothing to hide, and I'd very much like to keep that away from prying eyes.
 
No, I eventually found the solution.

This statement searches all records where field1 has value "textvalue" and field2 has value "12":

Code:
[...]
field1 = "NameOfField1"
field2 = "NameOfField2"
value1 = "textvalue"
value2 = "12"
    SearchString$ = field1 & " = " & """" & value1 & """" & " & " & field2 & " = " & value2
    Set GlobalCollection = db.SEARCH(SearchString$, Nothing, 0)
Indeed, SearchString$ results in:
NameOfField1 = "textvalue" & NameOfField2 = 12

As you see, the search string contains quotes: this can be accomplished in Visual Basic using "4-quotes method", i.e. """" :
string1 & """" & string2 & """" & string3 will result in aaa "bbb" ccc if string1="aaa", string2 = "bbb" and string3="ccc"

-- Jumpjack --
 
Note:
this new "discovery" allows easy statistical calculation on the database! db.SEARCH is very fast, and you can determine in a few seconds how many documents have a particular form and a certain value in a field:
How many documents use "MainForm" form and have "7" value in "DocIcon" field? That's easy:

Code:
field1 = "Form"
value1 = "MainForm"

field2 = "DocIcon"
value2 = "7"

SearchString$ = field1 & " = " & """" & value1 & """" & " & " & field2 & " = " & value2
Set GlobalCollection = db.SEARCH(SearchString$, Nothing, 0)

c=GlobalCollection.count


-- Jumpjack --
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top