Results 1 to 6 of 6

Thread: problem with ado control find method !!!

  1. #1

    Thread Starter
    Hyperactive Member eranfox's Avatar
    Join Date
    May 2001
    Posts
    492

    Unhappy 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:
    1. 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...

  2. #2
    New Member
    Join Date
    Aug 2003
    Posts
    4
    Have you tried

    Adodc1.Recordset.Find STR(sFieldName) & " like '*" & Trim(txtSearchFor.Text) & "*'", , adSearchForward, 0

  3. #3
    Addicted Member
    Join Date
    Aug 2003
    Location
    Singapore
    Posts
    245

    Lightbulb 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

  4. #4

    Thread Starter
    Hyperactive Member eranfox's Avatar
    Join Date
    May 2001
    Posts
    492

    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...

  5. #5
    New Member
    Join Date
    Aug 2003
    Posts
    2
    How about this...
    Adodc1.Recordset.Find (sFieldName) & " like '*" & Cstr(Trim(txtSearchFor.Text)) & "*'", , adSearchForward, 0

  6. #6

    Thread Starter
    Hyperactive Member eranfox's Avatar
    Join Date
    May 2001
    Posts
    492

    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
  •  



Click Here to Expand Forum to Full Width