Results 1 to 5 of 5
  1. #1
    Join Date
    Nov 2003
    Location
    Europe
    Posts
    369

    Question Unanswered: recordset search problem

    OK, what am I doing wrong here?:
    debug.print rst gives the following:
    10239 1 16.12.2003 51831 0
    10239 1 16.12.2003 51832 0
    10239 1 26.12.2003 76234 0
    10239 1 26.12.2003 76244 0
    (4 records)
    and
    debug.print me.txtid1 gives
    76234
    (correctly the current value on that field in my form)

    strID1 = cstr(me.txtid1)
    (when running the code and hovering over strID1 it shows "76234")

    then I rst.movefirst
    and
    rst.find strID1,,adSearchForward

    - and then Acces2002 says:
    "Run-time error '3001':
    Arguments are of the wrong type, are out of acceptable range, or are in conflict with one another."

    ?

    I also tried
    rstErate.MoveFirst
    rstErate.Find strFind, , adSearchForward
    rstErate.MoveFirst
    rstErate.Find "76234"
    rstErate.MoveFirst
    rstErate.Find "76234", , adSearchForward
    rstErate.MoveFirst
    rstErate.Find glTID, , adSearchForward
    (the latter is a long and has a number assigned when running this)

    But all of these return the same error...

    And when I try these:
    Me.RecordsetClone.FindFirst "TID = " & glTID
    Debug.Print Me.RecordsetClone!TID
    Me.RecordsetClone.FindFirst "TID = " & CStr(glTID)
    Debug.Print Me.RecordsetClone!TID
    Me.RecordsetClone.FindFirst "TID = " & CStr(glTID)
    Debug.Print Me.RecordsetClone!TID
    Me.RecordsetClone.FindFirst "TID = " & strFind
    Debug.Print Me.RecordsetClone!TID
    Me.RecordsetClone.FindFirst "TID = " & "76234"
    Debug.Print Me.RecordsetClone!TID
    Me.RecordsetClone.FindFirst "TID = " & 76234
    Debug.Print Me.RecordsetClone!TID

    They all pass without errors, but the debug.print output for each one gives the same TID number for all, namely the one of the record being shown on the form, not the one it actually seems to find using the recordsetclone.findfirst search.

    Can someone please explain how this works, what I am missing?

    D.

  2. #2
    Join Date
    Mar 2004
    Location
    www.scirocco.ca
    Posts
    346
    Your recordset is an ADO recordset, correct? Try doing this:

    rsData.Find "FieldName=76234", 1, adSearchForward, 1
    http://www.scirocco.ca/images/banner...occobanner.gif

    Download for FREE the ADO/DAO Data Controls that makes life EASIER developing database applications in: VB, FoxPro, Access, VC++, .NET etc... Navigate, Add New, Delete, Update, Search, Undo and Save your changes. Supports Disconnected Recordsets and Transactions!

    Or try our Ask An Expert service to answer any of your questions!

  3. #3
    Join Date
    Mar 2004
    Location
    www.scirocco.ca
    Posts
    346
    Your recordset is an ADO recordset, correct? Try doing this:

    rsData.Find "FieldName=76234", 1, adSearchForward, 1

    With FieldName being the name of the field in your recordset object.
    http://www.scirocco.ca/images/banner...occobanner.gif

    Download for FREE the ADO/DAO Data Controls that makes life EASIER developing database applications in: VB, FoxPro, Access, VC++, .NET etc... Navigate, Add New, Delete, Update, Search, Undo and Save your changes. Supports Disconnected Recordsets and Transactions!

    Or try our Ask An Expert service to answer any of your questions!

  4. #4
    Join Date
    Nov 2003
    Location
    Europe
    Posts
    369

    Arrow

    yes, ADO. I got it to work this way before I saw your answer:
    strFind = "[TID] = " & glTID
    rstErate.Find strFind

    When I use moveFirst and only does one search forward, is it important to include the adSearchForward? And what are the two 1's about?

    My function works now.

    D.

  5. #5
    Join Date
    Mar 2004
    Location
    www.scirocco.ca
    Posts
    346
    Here is the detailed description of the Find Method

    Find Method

    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.)
    http://www.scirocco.ca/images/banner...occobanner.gif

    Download for FREE the ADO/DAO Data Controls that makes life EASIER developing database applications in: VB, FoxPro, Access, VC++, .NET etc... Navigate, Add New, Delete, Update, Search, Undo and Save your changes. Supports Disconnected Recordsets and Transactions!

    Or try our Ask An Expert service to answer any of your questions!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •