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!!!!!!!!

Recommended Answers

All 15 Replies

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

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"
End If
Exit Sub
MsgBox Err.Description
End If
End Sub

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).

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

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

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)

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!!

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)

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

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

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

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.

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.

try using this code

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

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 "<Field name>='"& str &"'"

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.