Results 1 to 6 of 6

Thread: how to use rst.Find?

  1. #1
    Helger
    Guest

    Red face how to use rst.Find?

    ok it should be easy enough but...

    i used the find method before on numerical fields - no problem

    now i got a field called Code with a format like xyz999f.
    everytime i try to 'find' something i get an error telling me that my criteria is not of the correct type even if i enter the exact value of the current record.

    This is what i did:

    rstBio.Find "Code = AAA286F"

    result: error 3001

    tried also:

    rstBio.Find "Code = AAA286F")

    result: error 3001

    and:

    rstBio.Find("Code = 'AAA286F'"

    result: no error but also no record found although AAA286F exists



    it's the first field in the set. i got the following info about fields(0)

    .name = "code"
    .type = 202
    .value ="AAA286F"

    in the end i would like to search for the recordset that corresponds to the 'Code' a user picks from a combobox...
    and set this as the current record of the recordset all my textboxes are linked to.
    I hope find is a good method and if so how do i use it???
    I checked the msdn and a book and tried and...

    thx,

    Helger

  2. #2
    Hyperactive Member
    Join Date
    Jul 2001
    Location
    FL
    Posts
    258
    Try putting single quotes around your string
    You partially had it but in your examples the parenthenses messed up.

    rstBio.Find "Code = 'AAA286F'"

  3. #3
    Helger
    Guest

    Red face

    Thanks Mdake! That did the trick...

    Now I'm trying to put a variable there instead of the string and I don't get it...dont seem to bright with the find command

    Can you help with that too?

    regards

    Helger

  4. #4
    nullus
    Guest
    tried this?

    VB Code:
    1. rst.Find "Code = '" & strBlah & "'"

  5. #5
    Helger
    Guest
    thanks a lot that works fine!

    I'll never understand when to use which kind of quotes and in what order *sigh*

    For all who might have the same problem and are as 'talented' as I am, a short summary:

    numeric criteria:
    rec.find "fieldname = 34"

    date:
    rec.find "fieldname = #12.05.01#"

    string:
    rec.find "fieldname = 'string' "

    variable:
    rec.find "fieldname = ' " & variable & " ' "

    for the variable you can of course use something like a combobox text or the like as long as datatypes in the field and in combobox match (cboMycombo.text)


    thx,

    Helger

  6. #6
    Lively Member
    Join Date
    Aug 1999
    Location
    Malaysia
    Posts
    108

    Cool

    The clue is => when your variable is string you should use single quot like this rst.Find "Code = '" & varString & "'"
    when your variable is number you should do like this rst.Find "Code = " & varNumber

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