Hi Everybody,

Could somebody let me know the search code in a database (mdb database : with 1 table only) to write for a search command. I am using ADODC1 connection.

Please also let me know for the above table if i want to add a new contact to the table when i write contact name in a text box it should be automatically changed to upper case even i write in a lower case.

Have a nice day..

Note: I used this code for the search command but it did not work.

Private Sub Command8_Click()
Dim Searchvar As String
Dim sBookMark As String
Searchvar = InputBox("Enter the Name to find")
Searchvar = Trim$(Searchvar) 'remove surplus spaces
If Searchvar <> " " Then 'cancel if nothing entered
With Adodc1.Recordset
sBookMark = .Bookmark
.FindFirst "SName like '" + Searchvar + "*'"
If .NoMatch Then 'record not found
MsgBox "Hey! There is no such record in this Database
.Bookmark = sBookMark
End If
End With
End If
End Sub

When i tried this one there was an error: "Method or Data Member not found" and it highlights this string in the code : ".FindFirst"

user777

Why not just use DAO?

Much Cleaner in my opinion

Dim rst As DAO.Recordset
Dim db As Database
Set db = CurrentDb()
Set rst = db.OpenRecordset("select [field1],[field2] from table where [fieldID] = '" & Me.Something.Value & "'")
rst.Close
Set db = Nothing
End If

With Adodc1.Recordset
.FindFirst "SName like '" + Searchvar + "*'"
If .NoMatch Then 'record not found

Obviously "FindFirst" is not supported (neither "NoMatch"). But let's simulate it:

.MoveFirst
    .Find "SName like '" & Searchvar & "*'"
    If (.EOF) Then 'record not found

hi to all...

maybe this one will help...here it is:

********** this is an unbound control *************
***** create first and active connection ***********


Private Sub text1_KeyPress(KeyAscii As Integer)
dim RS as New ADODB.Recordset

If KeyAscii = 13 Then

set RS = new adodb.recordset
RS.open "select * from [tablename]",activeconnection,adOpenDynamic,
adLockOptimistic

with RS

.find "[fieldname] = '" & text1.text & "'", , adSearchForward

if not .eof then

msgbox "Record found."

else

msgbox "No Record."

endif

end with

End If

End Sub

hi to all...

maybe this one will help...here it is:

********** this is an unbound control *************
***** create first and active connection ***********


Private Sub text1_KeyPress(KeyAscii As Integer)
dim RS as New ADODB.Recordset

If KeyAscii = 13 Then

set RS = new adodb.recordset
RS.open "select * from [tablename]",activeconnection,adOpenDynamic,
adLockOptimistic

with RS

.find "[fieldname] = '" & text1.text & "'", , adSearchForward

if not .eof then

msgbox "Record found."

else

msgbox "No Record."

endif

end with

End If

End Sub

what if i want the result to be displayed on the textbox/listbox, then if i choose the name, the other info about the name that is chosen will change also to their corresponding info.. what will i do in this given code?.. =) hope you can help me guys!.. tnx a lot in advance..

Is there anyone here that can help me w/ my problem?

I'm trying to create Searching Code (using DAO).
how can I code this...
Database is MS Access 2003.
I want to search in my Database, in 1 table, 1 field and filter it.
for Example: if i just want to search all the records under year 2010, or Aug,2008
or from Aug-Nov 2008. Obviously, its just under DATE field. Is
that possible?

ComputerHacker, firstly please read our posting rules. You need to open your own thread with your question/problem. This is a VERY old post that has been reraised from the dead, and normally we would not even reply on this. You are however a new poster, so I'll answer the basics, and if you open your own thread we will help where we can.

Your question, yes it is possible, depending on your usage of getting the data, is it a datacontrol, ADO etc.?

Your code will look something like -

rsDate.Open "SELECT * FROM MyTable WHERE MyDate >= DateValue('" & txtDate.Text & "')", cnMyConnection, adOpenStatic, adLockOptimistic

Let us know if you encountered more problems in your OWN post please.

yes tnx for your reply...I admit I'm just a Newbee on this Forum...Can you just teach me how to Open a New Thread?

rsDate.Open "SELECT * FROM MyTable WHERE MyDate >= DateValue('" & txtDate.Text & "')", cnMyConnection, adOpenStatic, adLockOptimistic

how shall we use it under DATAENVIRONMENT for Reporting?

I Actually tried that before but it's not working in my program...I'm sorry if wasn't able to include in the post that I'm doing a Reporting as well...Can you please teach me...?

hai friends i am doing my final year project i have doubt please clear my doubt i create a form for address book for students i want to search the particular student data base like name,add,phno when i enter the name of the student what can i do for that i use backend as MS Access please help me if u know my email id: devakumar.indian@in.com

@Devakumar, you have just hijacked another members post, which is frowned upon here in Daniweb.:)

You need to open your own thread with the question by clicking on this link. Also, be more specific with your question, what database etc...

hi. who can help me that could output the length and what is their position. in the label you input this "THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG". in the text box you input a letter that could occur in that phrase. and if you click the command button a text MsgBox appear and a letter you input will appear and the position of the letter determine were it is. reminder the input should be small letter and the output is big letter. spaces are included.

example: if i enter "a" in the text box and i click the commandButton the msgBox appear that "Q is first occur, and the position is 5"

loether, try something on your own first, then you can be helped out if you encounter errors. Its the best way to learn

Could somebody let me know the search code in a database (mdb database : with 1 table only) to write for a search command. I am using ADODC1 connection.
my database is MySQL. i really need a code, for searching data.

No email address allowed. Incorrect forum - needs vb.Net not vb6. No effort shown.

Please see our posting rules. I have asked a moderator to move your post to .net. I am sure you will get a reply much faster from there. :)

Edited 3 Years Ago by AndreRet

This article has been dead for over six months. Start a new discussion instead.