954,559 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

ADO Data Control (ADODC) Problems with .recordset.find

Hi, I am using the Microsoft ADO Data Control 6.0 and connectiong to my database using Microsoft Jet 4.0. My fields are being outputted into labels.

I have a tex box called text1 and a command button called cmdsearch

I wand to be able to search through my database and pick out a perticular record. PLEASE HELP!!!!!!!!
A LEVEL COURSEWORK DEPENDS ON IT!!!!

uniquestar
Posting Whiz in Training
245 posts since Feb 2005
Reputation Points: 49
Solved Threads: 11
 

Can you show a bit of your code behind your form? I presume your building this in VB6 studio?

I can help you, just hang in there, give me a little more info. while i re-install vs 6.

I did something similar but I havn't touched data controls for about 4 years

hollystyles
Veteran Poster
1,182 posts since Feb 2005
Reputation Points: 262
Solved Threads: 68
 

Hi, this code is behind a command button, and workd when i'm @ home, but the same code will not work when at college, when i hit debug it highlights "adodc1.recordset.find tr"
Private Sub Command2_Click()
On Error GoTo abc
Dim tr As String
tr = InputBox("Criteria to Find", "Find")
If Len(Trim(tr)) > 0 Then
tr = "Title='" & UCase(Trim(tr)) & "'"
Adodc1.Recordset.Find tr
If Adodc1.Recordset.EOF = True Then
MsgBox "Record was not Found", vbInformation + vbOKOnly, "No Match"
Adodc1.Recordset.MoveFirst
End If
Exit Sub
abc:
MsgBox Err.Description
End If
End Sub
Cheers,
Jon

uniquestar
Posting Whiz in Training
245 posts since Feb 2005
Reputation Points: 49
Solved Threads: 11
 

Well it works fine for me too here!

What is the error text from debug ?

I note F1 on the Find method gets me nothing from MSDN Library which is disconcerting.

What ADO library have you got referenced (Project> references...) ?

Try simplifying the logic around your search string tr, I don't see the need for UCase as the search is not case sensitive by default and there's no need to test len(tr) because if it's blank your EOF test will handle the problem. I always try to code KISS (Keep It Simple Stupid).

hollystyles
Veteran Poster
1,182 posts since Feb 2005
Reputation Points: 262
Solved Threads: 68
 

Are you sure the control is pointing to the same directory and file path as it does on your own computer?

Comatose
Taboo Programmer
Team Colleague
2,910 posts since Dec 2004
Reputation Points: 361
Solved Threads: 215
 

That would error before you reached the call to the find method.

hollystyles
Veteran Poster
1,182 posts since Feb 2005
Reputation Points: 262
Solved Threads: 68
 

Hmn.... ok. And You are sure that the .mdb is the same one that you are using at home, and not corrupted in any way? (I know it seems like simple stuff, but the best of us forget the simple stuff some times)

Comatose
Taboo Programmer
Team Colleague
2,910 posts since Dec 2004
Reputation Points: 361
Solved Threads: 215
 

yeah, the database is the same, i just recreated the program at college and changed the paths to match, i just am really confused why one code works in one place but not another!!

uniquestar
Posting Whiz in Training
245 posts since Feb 2005
Reputation Points: 49
Solved Threads: 11
 

It should either not work on both, or work on both.... have you tried copying the from home and bringing it to the school? (instead of the recreation)

Comatose
Taboo Programmer
Team Colleague
2,910 posts since Dec 2004
Reputation Points: 361
Solved Threads: 215
 

Yeah, I 4got to take my flashdisk with me, I'm going to try that when i'm next in on tuesday.
Cheers

uniquestar
Posting Whiz in Training
245 posts since Feb 2005
Reputation Points: 49
Solved Threads: 11
 

Would you be willing to zip up your college proj files (the ones erroring) and mail them to me?

hollystyles
Veteran Poster
1,182 posts since Feb 2005
Reputation Points: 262
Solved Threads: 68
 

I'm next in on tuesday, and will do it then
cheers

uniquestar
Posting Whiz in Training
245 posts since Feb 2005
Reputation Points: 49
Solved Threads: 11
 

OK Guys, thanks for all your help, I copied my one from home into college and it now works. I have no idea what was wrong with it in college originally, but if/when i find i will let you know.
cheers.

uniquestar
Posting Whiz in Training
245 posts since Feb 2005
Reputation Points: 49
Solved Threads: 11
 

I got with the same code the errormessage Runtime Error 3001, arguments are the wrong type.
I can't see in the code with column is used.

achilles8
Newbie Poster
3 posts since Mar 2006
Reputation Points: 10
Solved Threads: 0
 

try using this code


adodc1.refresh
adodc1.refresh
adodc1.recordset.find "databasefield='" & trim(textfieldname.text) & "'"

allgotu
Newbie Poster
2 posts since May 2008
Reputation Points: 10
Solved Threads: 0
 

Hi,
Ok try this syntax

Take an variable of type serch data.

dim str as string

Now take an inputbox code as follows
str = inputbox ("Enter Name","Search")

then,put statement as follows
adodc1.recordset.find "='"& str &"'"

if the searching record is a Number type then type as follows
adodc1.recordset.find "='"& val(str) &"'"
then put condition to check record found or not
if adodc1.recordset.eof then
msgbox "Record not found"
else
text1.text = adodc1.recordset.fields(0)
text2.text = adodc1.recordset.fields(1)
endif
Remember that the value of fields is order by it is actual in database

hell_tej
Junior Poster in Training
53 posts since Apr 2008
Reputation Points: 15
Solved Threads: 3
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You