| | |
Search code in a database
![]() |
•
•
Join Date: Jul 2005
Posts: 19
Reputation:
Solved Threads: 0
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
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
•
•
Join Date: May 2005
Posts: 508
Reputation:
Solved Threads: 19
Why not just use DAO?
Much Cleaner in my opinion
Much Cleaner in my opinion
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
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
•
•
•
•
Originally Posted by user777
With Adodc1.Recordset
.FindFirst "SName like '" + Searchvar + "*'"
If .NoMatch Then 'record not found
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
.MoveFirst .Find "SName like '" & Searchvar & "*'" If (.EOF) Then 'record not found
Damn it, I still dream of her....:(
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
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
•
•
Join Date: May 2009
Posts: 1
Reputation:
Solved Threads: 0
•
•
•
•
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..
![]() |
Similar Threads
- search code not working!!! (VB.NET)
- ADODC Search code (Visual Basic 4 / 5 / 6)
- search record using search button from database (ASP)
- Dynamic Query (JSP)
- Tutorial: Search a Database (ASP)
Other Threads in the Visual Basic 4 / 5 / 6 Forum
- Previous Thread: Error in CreatematerilsTable
- Next Thread: Image Animation Help
| Thread Tools | Search this Thread |
* 6 2007 access activex add age basic beginner birth bmp calculator cd cells.find click client code college connection connectionproblemusingvb6usingoledb creat ctrl+f data database datareport date delete dissertations dissertationthesis dissertationtopic edit excel excelmacro file filename form header iamthwee image inboxinvb internetfiledownload listbox listview liveperson login looping microsoft movingranges number objectinsert open oracle password prime program prompt range-objects readfile reading remotesqlserverdatabase report save search sendbyte sites sql sql2008 sqlserver subroutine tags time urldownloadtofile vb vb6 vb6.0 vba visual visualbasic visualbasic6 web windows





