|
-
March 7th, 2006, 04:01 PM
#1
ADODB.Recordset Find method Help
Hello there,
Is there anyone who can tell me how to use the find method of the ADODB.Recordset object to find
parts of a date value.
For example:
I have a grid with a datacontrol which is connected to a database via odbc.
It is possible for the user to sort a column if he clicks on a columnhead, and i will move the recordpointer
to the correct record i he presses a key.
For example:
The grid is sorted on a column which is a date field.
iF the user presses 0, i will go to the first date which begins with 0, if he then presses 1 i will move
to the first date that begins with 01 and so on.
i do this with the following code:
rs is an ADODB.recordset which i have set to the database. To find the correct record i use the following code
rs.find mid(str(fld_date,1,2)) LIKE '01*', , adSearchForward, 1
when i run this i get the following error
runtime error 3001
Arguments are of the wrong type, are out of acceptable range or are in conflict with one another.
if fld_date was a character field it would have worked.
Can someone please help me to solve this problem.
THANKS!!
-
March 8th, 2006, 02:00 AM
#2
Re: ADODB.Recordset Find method Help
I never liked VB and fortunetly stopped to program in it sime time ago. So maybe Im wrong... but:
I suspect that it is an error connected to mid function which (as I believe) expect 1 or 2 parameters (and U specify non). And the str function .. I was (till now) pretty sure that it is for numeric expression (not for dates). And maybe there are NULLs in that table...
Try Format function instead or "(fld_date & '') LIKE '01*'" -maybe that helps.
Best regards,
Krzemo.
-
March 10th, 2006, 02:56 PM
#3
Re: ADODB.Recordset Find method Help
Obviously you have a type mismatch trying to compare a date type using a string comparison operator ... A solution would be to have a "match" column that formats your date as a string for this comparison purpose ... In other words, have an extra column that dups your date column as a string and run your find on it ...
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
|