|
-
Jul 17th, 2001, 12:47 PM
#1
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
-
Jul 17th, 2001, 02:54 PM
#2
Hyperactive Member
Try putting single quotes around your string
You partially had it but in your examples the parenthenses messed up.
rstBio.Find "Code = 'AAA286F'"
-
Jul 18th, 2001, 06:58 AM
#3
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
-
Jul 18th, 2001, 08:11 AM
#4
tried this?
VB Code:
rst.Find "Code = '" & strBlah & "'"
-
Jul 18th, 2001, 09:45 AM
#5
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
-
Jul 18th, 2001, 10:06 AM
#6
Lively Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|