-
Aug 17th, 2003, 06:26 AM
#1
Thread Starter
Hyperactive Member
problem with ado control find method !!!
Hello Everybody,
I'm using a ado data control and my problem is with the find method:
VB Code:
Adodc1.Recordset.Find sFieldName & " like '*" & Trim(txtSearchFor.Text) & "*'", , adSearchForward, 0
txtSearchFor.Text is a text box
when i'm searching on a string field i have no problem
but...
when i'm searching on a numeric field i get the following error:
Run-time error '-2147217881(80040e27)':
Find cannot be performed over the specified column,or compare
operator is invalid.
how can i use find on a numeric field ?
please H-E-L-P!!!
Thank you all in advance,
ERAN
Last edited by eranfox; Aug 17th, 2003 at 06:34 AM.
Eran Fox
ASSEMBLER,C,C++,VB6,SQL...
-
Aug 17th, 2003, 07:11 AM
#2
New Member
Have you tried
Adodc1.Recordset.Find STR(sFieldName) & " like '*" & Trim(txtSearchFor.Text) & "*'", , adSearchForward, 0
-
Aug 18th, 2003, 12:39 AM
#3
Addicted Member
May I suggest
May be this helps...
To search a numeric field the search Variables sholud be numeric too.
Either the Text or string be converted to integers like Cint(text).
Or CLng(text).
I may have interpret your post wrongly
Correct me if I made a mistake...
Hope This Helps.. .....Enjoy Coding.....//
zak2zak
-
Aug 20th, 2003, 02:49 AM
#4
Thread Starter
Hyperactive Member
Reply
Thank you both for your replies!
But,
sFieldName is the field(column) name so i cant put STR()
and if i try to use the search as a numeric type i get
when i'm searching on a numeric field i get the following error:
Run-time error '-2147217881(80040e27)':
Find cannot be performed over the specified column,or compare
operator is invalid.
Thank you again,
I hope you'll have better solutions for this...
ERAN
Eran Fox
ASSEMBLER,C,C++,VB6,SQL...
-
Aug 21st, 2003, 03:34 AM
#5
New Member
How about this...
Adodc1.Recordset.Find (sFieldName) & " like '*" & Cstr(Trim(txtSearchFor.Text)) & "*'", , adSearchForward, 0
-
Aug 21st, 2003, 05:20 AM
#6
Thread Starter
Hyperactive Member
Reply to eagle77
Hello eagle77 ,
Thank you for your reply,
I want to explain somthing:
Find Method (From the MSDN)
Searches a Recordset for the record that satisfies the specified criteria. If the criteria is met, the recordset position is set on the found record; otherwise, the position is set on the end of the recordset.
Syntax
Find (criteria, SkipRows, searchDirection, start)
Parameters
criteria A String containing a statement that specifies the column name, comparison operator, and value to use in the search.
SkipRows An optional Long value, whose default value is zero, that specifies the offset from the current row or start bookmark to begin the search.
searchDirection An optional SearchDirectionEnum value that specifies whether the search should begin on the current row or the next available row in the direction of the search. Its value can be adSearchForward or adSearchBackward. The search stops at the start or end of the recordset, depending on the value of searchDirection.
start An optional Variant bookmark to use as the starting position for the search.
Remarks
The comparison operator in criteria may be ">" (greater than), "<" (less than), "=" (equal), ">=" (greater than or equal), "<=" (less than or equal), "<>" (not equal), or "like" (pattern matching).
The value in criteria may be a string, floating point number, or date. String values are delimited with single quotes (for example, "state = 'WA'"). Date values are delimited with "#" (number sign) marks (for example, "start_date > #7/22/97#").
If the comparison operator is "like", the string value may contain "*" (one or more occurrences of any character) or "_" (one occurrence of any character). (For example, "state like M_*" matches Maine and Massachusetts.)
i cant search for 123 in 67123864 because 67123864 is a number from a numeric column,
In other words what can i do to make this work?
use another method?
in msaccess the find window knows how to find a numeric data - do you know how?
Thank you again for your reply,
ERAN
Eran Fox
ASSEMBLER,C,C++,VB6,SQL...
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|