Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
 
  HOME    TRACKER    Visual Basic




Database Searching


I have been stuck on a certain search for a month. I am searching my Access database by customer name, but sometimes you don't have the customers full name or don't know exactly how to spell it. So my problem is that my search, even though it's not case sensitive, can't search right unless you know exactly how the customers name is spelled. Here is my code:

Code:
Dim strQueryString As String, i As Integer
i = 1
strRenter = UCase(txtFind.Text)
strDate = txtDate.Text
strDate2 = txtDate2.Text
varBookMark = datTickets.Recordset.Bookmark
strQueryString = "Renter = '" & strRenter & "'"
ListView1.ListItems.Clear 'Clear list
If strRenter = "" Then
MsgBox "Enter the renter's name.", vbCritical, "Enter Renter's Name"
Exit Sub
End If
datTickets.Recordset.FindFirst strQueryString 'Find first one
It also searches the date when the customer was helped. The strRenter, strDate, and strDate2 are declared at the form level. This search works, but I have to type in john smith, I can't just type john, or smi, or whatever needed. This then displays to a listview. Any help you can give me I would appriciate very much.
Thank you




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Searching A Database Without Loading The Whole Database
I have a SQL database I am trying to search for just a few records at a time from. But when i pull over the datatable it loads the whole database. The database is so large it takes forever. What can i do just to pull the records I am searching for?

Thanks

Database Searching
Okay i wrote a program that takes text file information and uses a split function to save it it a text file, the fields are seperated by a comma.

Anyone know of any well written turts. to teach me how to make something to search them pending on something in the text field, the date or anything else.

Thanks

Brent

Searching A Database...
hi all,


i have a couple of questions for you.

im using vb6 and i have implemented a database using the adodc1 and the dataGrid components. i have made a text object and have used it to search for a record. my problem is, i have to search for a exact record eg. "Apples are red". I cant just search for "red" - is there anyway to search for anything within a feild's record?

also how can i toggle on and off to search every feild and not just the main one?


thanks heaps!

Searching A Database
I've got a variable called strSurname declared as a string. I'm trying to find the userid where the surname is found. When the SQL statement gets executed I get a [syntax error (missing operator) in query expression].
The SQL Statement reads "SELECT Userid FROM Users WHERE Surname = '" & strSurname & "'"
This statement works ok for all records except for one name where the surname is I'Anson which produces the error message. How can I adjust the SQL statement to take into account the apostrophe in that surname.
Thanks

Searching VSS Database
Hi all,

Does anyone know of a smooth way of searching a VSS database, other than Tools | Search inside of VSS? I need to search for 143 stored procedures in 8 different project folders. Ideally I'd love to be able to join with the sybase system tables, but I'm sure I'm really wishing there.

All suggestions welcome..

Frances

Help Searching Database
I have a text box that the user can type a name and then a search button that returns values in a flexgrid. Now I can search on a person full name, ex: John Q. Smith. But if I just type in John, or Smith, I get an error that says "either BOF or EOF is true,or the current record is deleted, etc...

How can I just search on any part of the name?

Heres the code I am using.

Code:
Private Sub cmdSearchBios_Click()

Screen.MousePointer = vbHourglass
Call CreateConnection(objConn)

MSFlexGrid1.Clear
MSFlexGrid1.Rows = 1

Set objRs = New ADODB.Recordset

objRs.ActiveConnection = objConn
objRs.CursorLocation = adUseClient
objRs.CursorType = adOpenDynamic
objRs.LockType = adLockOptimistic
objRs.Source = "select * from Bios where tm_name ='" & txtFindBio.Text & "'"
'MsgBox objRs.Source
objRs.Open

While Not objRs.EOF()
'MsgBox objRs!tm_name
'ADDING RECORDS TO FLEXGRID
MSFlexGrid1.AddItem objRs!tm_name & Chr(9) _
& objRs!tm_title & Chr(9) _
& objRs!tm_id & Chr(9)

objRs.MoveNext

Wend

Set objRs = Nothing

Call CloseConnection(objConn)
Screen.MousePointer = vbDefault
End Sub

Searching Database With ADO
Hello,

I want to be able to search for a specific record in a datagrid. And I want to be able to search, using a textbox and submit button, on a remote form. I have a Book database that I am using, I want to search for the title of the book and highlight that record in the datagrid. So this is the process... I start at the Search Title Form (frmTitle) and contains a textbox (txtTitle) and a Submit button (cmdTitleSubmit). Then I type in the name of the book I want to search for and hit the Submit Button. (The Submit Button should be coded to search for the title of the book in the datgrid in the next form.) The Submit button then brings up another form (frmDatabase) which contains my datagrid (dgddatabase) and my adodc (adodatabase), the record that corresponds with my search terms is highlighted. And I want it setup so that it clears the records and displays only the records that relate to my search terms.

My code I have so far is below...

frmDatabase.adoDatabase.RecordSource = "SELECT * FROM tblDatabase WHERE (title) like '" & txtTitle.Text & "%'"
frmDatabase.adoDatabase.Refresh
frmDatabase.Show

But it comes up with these error messages...
"No value given for one or more required parameters."
AND
Run-time error '-2147217904 (80040e10)': Method 'Refresh' of object 'IAdodc' failed.

I have been trying to figure what the error message is saying but I dont know at the moment what is wrong.

Help!! Thanks for your time!!!

Searching Database
I want to use a list box to display the contents of a particular column (Project Name) in a table situated in the database. I thought of having the list box's data field as the same field i want to display but it just takes the first record in the column. How do i fix this?

I also would like to have the information on the selected Project (from the list box) displayed in a series of labels how would i do this.

If it helps i can put the form and database up in another post.

Searching The Database...
Just wondering, is it possible to search a database for a field on form 1, and then to display the result on form 2?

Also is there a way of setting out the row nicely on the form, for example, if the row in the database looked like :

4 2 10 Broke

would it be possible to put each of the items into seperate labels on the form 2?

thanx in advance!

Searching A Database !!!! Please Help
I have been working on this problem since last Friday and Iam as frustrated as ever!
Here's the problem:

My database contains a field called "entry". I want to be able to...
1) click a command button that I have named "Search"
2) enter search criteria
3) have VB search through the "entry" field of all my records and display records that contain my search criteria.

For ex: I enter "PA"
One of my records contains "abandoned mine of PA" in the field "entry"

My goal is for the computer to find and display any records that contain “PA”.


I have the following line in declarations:
Private db As ADODB.Connection

My load form code is as follows:
[code]

Private Sub Form_Load()

Set db = New Connection

Dim rs As ADODB.Recordset
Set rs = New Recordset

db.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:gentestGen_Cards.mdb;"
rs.Open "SELECT * FROM Cards", db, dbOpenKeyset

End Sub
___________________________
My search command code is as follows:
[code]
Private Sub Command1_Click()

Dim sSQL As String
Dim rs As ADODB.Recordset
Dim INQUIRE As String

INQUIRE = InputBox("Enter search criteria:")

sSQL = "SELECT entry FROM cards WHERE entry LIKE '%" & INQUIRE & "%'"

Set rs = New ADODB.Recordset

rs.Open sSQL, db

End Sub

Here is what is supposed to happen:
1) An input box appears when I click the "search" button
2) I enter whatever phrase or word that I want to search for
3) The program searches through the "entry" field of all records
4) displays the first record it finds that matches the search

Everything seems fine. No error messages. However, after I enter the search criteria and click ok... nothing happens.
It is my understanding that the problem is because my fields are bound to the datacontrol and my search is contained in a coded recordset. I have tried using a MSHFlexgrid but can’t seem to figure out how to get the new recordset bound to it. This has been a lot more confusing than I ever anticipated. But maybe it’s just me!
Do I need to open a new form to display the new recordset?

Cinnamon

Searching A Database
Hi,
I was wondering whether anyone could help. i need to search i database i created using Visual Basic. i'm pretty handy with SQL, and i can get the desired results when searching in access but i want to make a VB form so that people without SQL knowledge can search. there are multiple fields that i want to search, or give the user the option of searching just one. i have very little VB knowledge so i need it explained step by step. thanks for any help.

Searching Database
anyone knows where i can find reference/tutorial on "searching from database" using combox or datacombo, textbox that works exactly like MSDN search.

Searching Through Database
hey all...

I have the following code that is designed to search through database and display corresponding information on the form.

If (txtCurrentSearch.Text > 1) And (txtCurrentSearch.Text < 99999) Then

For x = 1 To Countdata

If txtCurrentSearch.Text = CurrentSubNum(x) Then

lblCurrentNewSubNum.Caption = "Subscription Number - " & CurrentSubNum(x)
lblCurrentName.Caption = "Name - " & CurrentName(x)
lblCurrentAddress.Caption = "Address - " & CurrentAddress(x)
lblCurrentSex.Caption = "Sex - " & CurrentSex(x)
lblCurrentSubDate.Caption = "Last Subscription Date - " & CurrentSubDate(x)
cmbCurrentSubType.Text = CurrentSubType(x)
cmbCurrentSubAge.Text = CurrentSubAge(x)
End If

Next x

End If

I have only 7 subscription numbers in the database, which range from 10001 - 10007. i want a message box to appear if the number entered does not match the number in the database.
Does anyone know how i can achieve this?

thanks for ya help...

DK

VB6 Database Searching
I would like to write back to a database, but only edit a specific line.
how can i do this without having to writeover the whole database:

PLEASE I NEED YOUR HELP

dkeegh

Searching A Database
I have a text box in which a user would be in the keyboard they are looking for in the database. Then I have a button the press to perform the search.

Question is what would the code look like to search the entire database for records that contain the keyword then display the matches only.

Need A Little Help With Searching A Database
I have been able to figure out how to get what i want loaded into a datagrid viewer on a form the only thing i'm having trouble with is how to i use what is typed in a textbox as the search agent (i.e. a last name) below is the code i have so far...What i have learned is mostly from reading books and trial and error so if anyone has a better way of doing this i'm eager to learn.

Code:
Private Sub FindCustomerButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles FindCustomerButton.Click
Dim cn As New SqlClient.SqlConnection()
Dim cmd As New SqlClient.SqlCommand()
Dim da As New SqlClient.SqlDataAdapter()
Dim ds As New DataSet()

Try
cn.ConnectionString = "Data Source=STORMSQLEXPRESS;Initial Catalog=customers.mdf;Persist Security Info=True"
cn.Open()

cmd = cn.CreateCommand
cmd.CommandText = "SELECT LastName FROM customers"
da.SelectCommand = cmd
da.Fill(ds, "Customers")
cn.Close()

CustomersDataGridView.DataSource = ds
CustomersDataGridView.DataMember = "Customers"

Catch ex As Exception
MsgBox("Error: " & ex.Source & ": " & ex.Message, _
MsgBoxStyle.OkOnly, "FindCustomerButton")

End Try
End Sub

Searching Database
I have created student database in MS Access name "Student.mdb" table name is "student list" table having four fiedls name 1.Registration No, 2.Student Name, 3.standard, 4. city . In vb i have designed one form "frmsearch" in that i have placed one text box name "txtsearch, two option button, name "optsearchmode Regno" & "optsearch mode alphabetical " and on datagrid contol & one command button name "cmdsearch"

My question is
1. user optsearch mode Regno and enter Regno in txt search and click seach command button the resulat will display MessageBox, Found Or not.

2. user optsearch mode alphabetical and enter *A* in txt search and click search command button the resulat will display in Datagrid control only the name begin with A.

how to wite the code for above my question

Note: I am connecting the database using ADODC

awaiting your valuable reply

thanking you

Searching Through A Database
Hi,

Let say I have a list box and connected and pulled a database for Client Names. I would like to type in the name and it would appear automatically. How do I do that? Can someone help?

Thanks

Database Searching
hi,

i am newish the VB i have connected to a database and have been able to display all the data from the database. can you to explain how i can search a sql database for a specific result from a user textbox. and display the result. thanks.

Searching A Database
I have a vb form with an excel database. The fields are shown in individual text boxes. I want to be able to have the use input a search term in a text box and be able to pull up the corresponding record in the database. Any suggestions?

Searching A Database HELP
how do you search a database using an ADO control to find a string in a field.
thanks

Searching A Database
I want to write an informational program that people can search something and if a form has any keywords that they search, it displays a link to that form in a listbox or something. Any suggestions?

Searching In SQL Database
I am not sure if this topic has been posted somewhere. But I am working in a project for collage. I am having some problems. If anyone could help..

Here's my program code:

Code:
Dim con As New ADODB.Connection
Dim rs As New ADODB.Recordset
Private Sub Command1_Click()
Dim objform2 As Form2
Set objform2 = New Form2
objform2.Show
End Sub

Private Sub Form_Load()

con.Open "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=InstManagement;Data Source=MYHOMEPC"

rs.Open "Select * from Student", con, adOpenDynamic, adLockBatchOptimistic
On Error Resume Next

StudID.Text = rs(0)
FName.Text = rs(1)
LName.Text = rs(2)
GardianName.Text = rs(3)
DOB.Text = rs(5)
Gender.Text = rs(4)
Edu_Quali.Text = rs(6)
Proff_Quali.Text = rs(7)
Remarks.Text = rs(8)
Hno.Text = rs(9)
Street.Text = rs(10)
City.Text = rs(11)
State.Text = rs(12)
Pincode.Text = rs(13)
Contactno.Text = rs(14)
RegDate.Text = rs(15)
CourseName.Text = rs(17)
CourseFee.Text = rs(19)
RegFee.Text = rs(16)
Batch.Text = rs(18)
ModePayment.Text = rs(20)
End Sub

Private Sub add_Click()
On Error Resume Next
If add.Caption = "ADD" Then
StudID.Text = rs(0)
FName.Text = " "
LName.Text = " "
GardianName.Text = " "
DOB.Text = " "
Gender.Text = " "
Edu_Quali.Text = " "
Proff_Quali.Text = " "
Remarks.Text = " "
Hno.Text = " "
Street.Text = " "
City.Text = " "
State.Text = " "
Pincode.Text = " "
Contactno.Text = " "
RegDate.Text = " "
CourseName.Text = " "
CourseFee.Text = " "
RegFee.Text = " "
Batch.Text = " "
ModePayment.Text = " "
rs.AddNew
StudID.SetFocus
End If
End Sub

Private Sub delete_Click()
On Error Resume Next
s = Val(InputBox("Enter the Student_Id"))
i = "delete from Student where Student_Id=" & s
Set rs = con.Execute(i)
Set rs = Nothing
rs.Open ("Student"), con, adOpenDynamic, adLockBatchOptimistic
rs.Update
rs.MoveFirst

StudID.Text = rs(0)
FName.Text = rs(1)
LName.Text = rs(2)
GardianName.Text = rs(3)
DOB.Text = rs(5)
Gender.Text = rs(4)
Edu_Quali.Text = rs(6)
Proff_Quali.Text = rs(7)
Remarks.Text = rs(8)
Hno.Text = rs(9)
Street.Text = rs(10)
City.Text = rs(11)
State.Text = rs(12)
Pincode.Text = rs(13)
Contactno.Text = rs(14)
RegDate.Text = rs(15)
CourseName.Text = rs(17)
CourseFee.Text = rs(19)
RegFee.Text = rs(16)
Batch.Text = rs(18)
ModePayment.Text = rs(20)
MsgBox "DATA DELETED"
End Sub

Private Sub exit_Click()
Unload Me
End Sub

Public Sub find_Click()
On Error Resume Next
s = Val(InputBox("enter the Stdent_Id"))
i = "select * from Student where student_id=" & s
Set rs = con.Execute(i)
If rs.RecordCount = 0 Then

MsgBox "sorry"
Else
If i <> rs.BOF And rs.EOF <> True Then

StudID.Text = rs(0)
FName.Text = rs(1)
LName.Text = rs(2)
GardianName.Text = rs(3)
DOB.Text = rs(5)
Gender.Text = rs(4)
Edu_Quali.Text = rs(6)
Proff_Quali.Text = rs(7)
Remarks.Text = rs(8)
Hno.Text = rs(9)
Street.Text = rs(10)
City.Text = rs(11)
State.Text = rs(12)
Pincode.Text = rs(13)
Contactno.Text = rs(14)
RegDate.Text = rs(15)
CourseName.Text = rs(17)
CourseFee.Text = rs(19)
RegFee.Text = rs(16)
Batch.Text = rs(18)
ModePayment.Text = rs(20)
Else

StudID.Text = rs(0)
FName.Text = rs(1)
LName.Text = rs(2)
GardianName.Text = rs(3)
DOB.Text = rs(5)
Gender.Text = rs(4)
Edu_Quali.Text = rs(6)
Proff_Quali.Text = rs(7)
Remarks.Text = rs(8)
Hno.Text = rs(9)
Street.Text = rs(10)
City.Text = rs(11)
State.Text = rs(12)
Pincode.Text = rs(13)
Contactno.Text = rs(14)
RegDate.Text = rs(15)
CourseName.Text = rs(17)
CourseFee.Text = rs(19)
RegFee.Text = rs(16)
Batch.Text = rs(18)
ModePayment.Text = rs(20)
End If
End If
End Sub

Private Sub first_Click()
On Error Resume Next
rs.MoveFirst

StudID.Text = rs(0)
FName.Text = rs(1)
LName.Text = rs(2)
GardianName.Text = rs(3)
DOB.Text = rs(5)
Gender.Text = rs(4)
Edu_Quali.Text = rs(6)
Proff_Quali.Text = rs(7)
Remarks.Text = rs(8)
Hno.Text = rs(9)
Street.Text = rs(10)
City.Text = rs(11)
State.Text = rs(12)
Pincode.Text = rs(13)
Contactno.Text = rs(14)
RegDate.Text = rs(15)
CourseName.Text = rs(17)
CourseFee.Text = rs(19)
RegFee.Text = rs(16)
Batch.Text = rs(18)
ModePayment.Text = rs(20)
End Sub

Private Sub last_Click()
On Error Resume Next
rs.MoveLast

StudID.Text = rs(0)
FName.Text = rs(1)
LName.Text = rs(2)
GardianName.Text = rs(3)
DOB.Text = rs(5)
Gender.Text = rs(4)
Edu_Quali.Text = rs(6)
Proff_Quali.Text = rs(7)
Remarks.Text = rs(8)
Hno.Text = rs(9)
Street.Text = rs(10)
City.Text = rs(11)
State.Text = rs(12)
Pincode.Text = rs(13)
Contactno.Text = rs(14)
RegDate.Text = rs(15)
CourseName.Text = rs(17)
CourseFee.Text = rs(19)
RegFee.Text = rs(16)
Batch.Text = rs(18)
ModePayment.Text = rs(20)
End Sub

Private Sub next_Click()
On Error Resume Next
rs.MoveNext
If rs.EOF <> True Then

StudID.Text = rs(0)
FName.Text = rs(1)
LName.Text = rs(2)
GardianName.Text = rs(3)
DOB.Text = rs(5)
Gender.Text = rs(4)
Edu_Quali.Text = rs(6)
Proff_Quali.Text = rs(7)
Remarks.Text = rs(8)
Hno.Text = rs(9)
Street.Text = rs(10)
City.Text = rs(11)
State.Text = rs(12)
Pincode.Text = rs(13)
Contactno.Text = rs(14)
RegDate.Text = rs(15)
CourseName.Text = rs(17)
CourseFee.Text = rs(19)
RegFee.Text = rs(16)
Batch.Text = rs(18)
ModePayment.Text = rs(20)
Else
rs.MoveLast
MsgBox "THIS IS LAST RECORD"

StudID.Text = rs(0)
FName.Text = rs(1)
LName.Text = rs(2)
GardianName.Text = rs(3)
DOB.Text = rs(5)
Gender.Text = rs(4)
Edu_Quali.Text = rs(6)
Proff_Quali.Text = rs(7)
Remarks.Text = rs(8)
Hno.Text = rs(9)
Street.Text = rs(10)
City.Text = rs(11)
State.Text = rs(12)
Pincode.Text = rs(13)
Contactno.Text = rs(14)
RegDate.Text = rs(15)
CourseName.Text = rs(17)
CourseFee.Text = rs(19)
RegFee.Text = rs(16)
Batch.Text = rs(18)
ModePayment.Text = rs(20)
End If

End Sub

Private Sub previous_Click()
On Error Resume Next
rs.MovePrevious
If rs.BOF <> True Then

StudID.Text = rs(0)
FName.Text = rs(1)
LName.Text = rs(2)
GardianName.Text = rs(3)
DOB.Text = rs(5)
Gender.Text = rs(4)
Edu_Quali.Text = rs(6)
Proff_Quali.Text = rs(7)
Remarks.Text = rs(8)
Hno.Text = rs(9)
Street.Text = rs(10)
City.Text = rs(11)
State.Text = rs(12)
Pincode.Text = rs(13)
Contactno.Text = rs(14)
RegDate.Text = rs(15)
CourseName.Text = rs(17)
CourseFee.Text = rs(19)
RegFee.Text = rs(16)
Batch.Text = rs(18)
ModePayment.Text = rs(20)
Else
rs.MoveFirst
MsgBox "THIS IS FIRST RECORD"

StudID.Text = rs(0)
FName.Text = rs(1)
LName.Text = rs(2)
GardianName.Text = rs(3)
DOB.Text = rs(5)
Gender.Text = rs(4)
Edu_Quali.Text = rs(6)
Proff_Quali.Text = rs(7)
Remarks.Text = rs(8)
Hno.Text = rs(9)
Street.Text = rs(10)
City.Text = rs(11)
State.Text = rs(12)
Pincode.Text = rs(13)
Contactno.Text = rs(14)
RegDate.Text = rs(15)
CourseName.Text = rs(17)
CourseFee.Text = rs(19)
RegFee.Text = rs(16)
Batch.Text = rs(18)
ModePayment.Text = rs(20)
End If
End Sub

Private Sub save_Click()
If save.Caption = "SAVE" Then
rs(0) = StudID.Text
rs(1) = FName.Text
rs(2) = LName.Text
rs(3) = GardianName.Text
rs(4) = Gender.Text
rs(5) = DOB.Text
rs(6) = Edu_Quali.Text
rs(7) = Proff_Quali.Text
rs(8) = Remarks.Text
rs(9) = Hno.Text
rs(10) = Street.Text
rs(11) = City.Text
rs(12) = State.Text
rs(13) = Pincode.Text
rs(14) = Contactno.Text
rs(15) = RegDate.Text
rs(17) = CourseName.Text
rs(19) = CourseFee.Text
rs(16) = RegFee.Text
rs(18) = Batch.Text
rs(20) = ModePayment.Text
rs.UpdateBatch
End If
MsgBox "DATA SAVED"
End Sub


This code is running well but at some points I want to improve this program:
* in Save_Click() function : I want a function to search in SQL whether studentID already exist, if it does then program show a dialog box saying "StudentID already exist" and user can input different studentID. (Can I also make it that user don't have to re-enter the entire data again?)

* In Find_Click() : Here if function doesn't work.

Code:
If rs.RecordCount = 0 Then
MsgBox "sorry"
Else
code....

instead of checking rs.recordcount it directly go to else part. If record doesn't found it shows error instead of showing "Sorry" in msgbox.

* I added a sub function later with save_click() the program but it doesn't work too.

Code:
public sub checkid()
if val(studID.text)=rs(0) then
msgbox "StudentID already exist. Enter another StudentID"
else
rs.updatebatch
end sub

and added it with save_click() function in the end.
it shows the msgbox and run rs.updatebatch both at the same time. I know i am doing some mistake here....

Can anyone give me there suggestion...

Thank You in Advance

Searching A Database Help
this is my search engine in my program it works but I want it to be a little more specific when I search the ratings part of my database. for instance if I were to search for a PG movie it will also list the G and PG-13 movie as well I just want it to list the specific one i'm searching. this is my code.


VB Code:
Private Sub cmdSearch_Click()    lstMovies.ListItems.Clear        strSearch = "[" & cboSearchType.Text & "] Like '*" & txtSearchText.Text & "*'"            With rsMovies        .FindFirst strSearch        If .NoMatch Then            MsgBox "Your search is complete. There are no movies with  """ & txtSearchText.Text & """  in the  """ & cboSearchType & """  section.", 16, "Search Complete"            Exit Sub        Else            Set a = lstMovies.ListItems.Add(, , .Fields("Title"), , 2)            a.SubItems(1) = "(" & .Fields("MovieDate") & ")"            frmMain.Again strSearch        End If    End With End Sub

Database Searching
I have changed my program and can't figure out how to change my search in
my program to make it work with the way I changed my program around.
Ok, This is a movie program and I used to have the credits(actors names)
in with the movie itself and my search program worked then. I have recently
changed my program around a little to make the actors names associate with
the character they play in that movie, in witch I took the credits part out of
the movies section and made a table called tblactors, and it associates with
the character table call tblactorlink.
tblactor would look something like this
actorID----actor_name----movieID

tblactorlink
Lactor_ID----char_name----movieID

This is my code that worked before I changed my program

VB Code:
frmMain.StatusBar.Panels(1) = "You are currently Searching for " & Chr(34) & txtSearchText.Text & Chr(34) & " in the " & cboSearchType.Text & " Section" & Chr(34)    frmMain.lstMovies.ListItems.Clear    strSearch = "[" & cboSearchType.Text & "] Like '*" & txtSearchText.Text & "*'"  With rsMovies        .FindFirst strSearch        If .NoMatch Then            MsgBox "Your search is complete. There are no movies with  """ & txtSearchText.Text & """  in the  """ & cboSearchType & """  section.", 16, "Search Complete"        Else            Set a = frmMain.lstMovies.ListItems.Add(, , .Fields("Title"), , 2)            a.SubItems(1) = Replace(rsMovies.Fields("Genre"), "§", ", ")            If Right$(a.SubItems(1), 2) = ", " Then a.SubItems(1) = Left$(a.SubItems(1), Len(a.SubItems(1)) - 2)            a.SubItems(2) = .Fields("Director")            a.SubItems(3) = .Fields("Credits")            a.SubItems(4) = .Fields("Rating")            a.SubItems(5) = .Fields("MovieDate")            a.SubItems(6) = .Fields("Type")            frmMain.Again strSearch        End If    End With    txtSearchText = ""    Me.Hide

If you require anymore info just ask because I'd really like to get this working
again, Thank you for your time.

Searching Database
im making a projet wherein i will search for an available room in a hotel. i have to search my database first with the type of room, and/or room no., then if its available for the given date. i dont have any code because i dont know how to do this.

Searching Database
i have a new question, i need to search my database and output the search result in the datagrid or table. and i should be able to edit or update that table. im only a beginner in visual basic and i only know the basic of VB, pls help

Searching A Database
Dear all,

I want to use a form with a text box called txtCitySearch.text to look for city names in a databse. The user should be able to enter a value then click command button 'cmdCitySearch' to locate results.

My db is called details.mdb and table where field 'City' is located can be found in a table called 'Details'

Can anyone please help me with the code, how would I then display these results????


Regards,
Colin

Searching To Database
How about searching thru database? Can anyone help me on this. At present I have created some forms where the user will key in information in the textbox and the information will then save into a sql server. What I want is to retrieve back the data by searching thru a indentical number for example. Can you help me on this...thanks in advance

Searching In Database
Hi there,

I have a simple problem, I have a combo box where I have names of certain cities & two text box which is for latitude & longitude. I have already entered all these in a access file (DAO) now what I want is when I click on any place the long & latitude should get displayed. Please Help

Thanking u & waiting for some kind replies.

arv

Searching A Database
Hey there.

I want to search a database.. and if there are no exact matches
... show a list of the closest ones. I want to do this all programmaticly (with out a control)...

Anyone able to help me?

Searching A Database
My form currently has a combo box, a text box, a command button and a flexi grid. The combo box currently displays all the fields in my database.

What I would like to do is search for a record(s) with specified data in a specfic field and display the results in the flexi grid. I would like to be able to specify the field by selecting it from the combo box unless theres an easier way.

Thanks for your time

Searching Database
Guys,

I have an Access database and I want to put search option on my form (like KEYWORD search), it should be able to get from any field of the table.

Can some one help me???

Thanks in advance

Searching A Database
In my small football management game, I am using an Access database to hold all information about the players. They are held in tables, by "regions" such as Europe, Africa, Asia etc, all of which are identical, except for the info held within them... I am currently using the following code to search for players:

select * from [Europe] Order by [Name]

What I want to be able to do is search more than one region at a time, for example the user wants to find players from Europe and Asia...

How would I do this?

Searching A Database
OK.. Here goes. I made a datbase using Acess 97 all goes fine and good and the fields work. I can add subtract and do logs at the same time. he he . Humor. Anyway I need to search the datbase I made the code to search as follows however it fails to work. If you can please help. Post either how to fix this or ever start from the beggining I am willing to read.

prompt$ = "Enter the full (complete) criteria."
SearchStr$ = InputBox(prompt$, "Search")
Data1.Recordset.Index = ""
Data1.Recordset.Seek "=", SearchStr$
If Data1.Recordset.NoMatch Then
Data1.Recordset.MoveFirst
End If

Searching Database ?
I am using the following statement to search through a database.
Set RS = DB.OpenRecordset("SELECT * FROM Table1 WHERE '" & SearchField & "' = '" & KeyWord & "'", dbOpenDynaset)

Where "SearchField" and "Keyword" are the variables entered by the program user. But the problem is that the above statement does not result in any records relating to user specified keyword but always displays the first record in the database.
No errors are shown at runtime.

Please help.


Kinjal

[Edited by kinjalgp on 06-27-2000 at 01:32 PM]

Searching A Database
If someone would be kind enough to give me a segment of code to search a database for a Like statement I would be please

Evan

PS. My comp crashed and i lost all my code. grr

Database Searching
Hi all - total newbie to DB programming, so bear with me....

I am using a Recordset object, and am trying to implement a search, but am
not having luck finding what I need.

I would like to enter a partial name, and seek records that contain that
string, rather than equal it. All I can find for relational operators are
=, <=, >=, >, and <.

How would I go about doing a "contains" search?

Thanks!

Searching Database
hi! I dont know how to search my database. actually i'm just using the biblio.mdb here's my code. pls check it. tnx...

Code:

Option Explicit
Dim row As Integer
Dim myrsql As New ADODB.Recordset
Dim mysqlql As String
Dim custfield As String

Private Sub Combo1_Click()
    ListView1.ListItems.Clear
    Text1.Text = ""
    If Not Combo1.Text = "Select" Then
        Text1.Enabled = True
        Select Case Combo1.ListIndex
        Case 0
        custfield = "title"
        Case 1
        custfield = "year published"
        Case 2
        custfield = "pubID"
        Case 3
        custfield = "ISBN"
        Case 4
        custfield = "DESCRIPTIONS"
        Case 5
        custfield = "NOTES"
        Case 6
        custfield = "SUBJECT"
        Case 7
        custfield = "COMMENTS"
        End Select
    Else
        Text1.Enabled = False
    End If
End Sub
Private Sub Combo1_KeyPress(KeyAscii As Integer)
    KeyAscii = 0
End Sub
Private Sub Command1_Click()
    Unload Me
End Sub

Private Sub Form_Load()
   mysqlq1 = "Select * from titles"
   myrsql.Open mysqlq1, conName, adOpenKeyset, adLockPessimistic
   row = 1
  Text1.Enabled = False
   custfield = ""
End Sub

Private Sub Form_Unload(Cancel As Integer)
myrsql.Close
End Sub

Private Sub Text1_Change()
    ListView1.ListItems.Clear
    row = 1
    Search (Text1.Text)
End Sub

Private Sub Search(code As String)
Dim ctr, ctr2 As Integer
myrsql.MoveFirst
ListView1.ListItems.Clear
While Not myrsq1.EOF
    If Trim(CStr(UCase(myrsql.Fields(custfield)))) Like Trim(CStr(UCase("*" & code & "*"))) Or Trim(CStr(myrsq1.Fields(custfield))) Like Trim(CStr(LCase("*" & code & "*"))) Then
        ListView1.ListItems.Add row, , myrsq1(0)
        ListView1.ListItems(row).SubItems(1) = myrsql(1)
        ListView1.ListItems(row).SubItems(2) = myrsq1(2)
        ListView1.ListItems(row).SubItems(3) = myrsq1(3)
        ListView1.ListItems(row).SubItems(4) = myrsq1(4)
        ListView1.ListItems(row).SubItems(5) = myrsq1(5)
        ListView1.ListItems(row).SubItems(6) = myrsq1(6)
        ListView1.ListItems(row).SubItems(7) = myrsq1(7)
        ListView1.ListItems(row).SubItems(8) = myrsq1(8)
        ListView1.ListItems(row).SubItems(9) = myrsq1(9)
        ListView1.ListItems(row).SubItems(10) = myrsq1(10)
        ListView1.ListItems(row).SubItems(11) = myrsq1(11)
        ListView1.ListItems(row).SubItems(12) = myrsq1(12)
        row = row + 1
    End If
    myrsq1.MoveNext
Wend
End Sub

Database Searching
Hello all,

I have recently created an address book using databases etc.. I have used an ADO to link it to an Access file etc, and it works fine.. I can navigate it easily, delete and add entries at will..

However, I want to be able to click a button, and be able to search (using names) the database... How would I do this (I know it's possible)

Thank you in advance.

ADO Database Searching
I've got a problem with searching an Access database when using an ADO Recordset.
Using the code below to search a Field named REG in a Table named tbl_Master, if I enter a complete REG number in the textbox named txtReg and click the RegSrch command button I get returned the info on the matching Reg number. The problem is if I dont know the full Reg number, no match is returned, so how can I get it to search if I only enter the first three numbers of the Reg so it returns all possible matches.


Option Explicit
Private rsSearch As ADODB.Recordset

Private Sub Form_Load()
Me.MousePointer = 11
    Set cn = New ADODB.Connection
      cn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" & "Data Source = C:windowsdesktopdb10.mdb"
      cn.Open
    Set rsSearch = New ADODB.Recordset
      rsSearch.Open "tbl_master", cn, adOpenKeyset, adLockPessimistic, adCmdTable
Me.MousePointer = 0
End Sub

Public Sub fillfields()
    If Not (rsSearch.BOF = True Or rsSearch.EOF = True) Then
        Text1.Text = rsSearch.Fields("field2") 'INSURANCE COMPANY
        Text2.Text = rsSearch.Fields("surname") 'SURNAME
        Text4.Text = rsSearch.Fields("Our Ref") 'OUR REF
        Text5.Text = rsSearch.Fields("field1") 'CONDITION
    Else
        End If
End Sub

Private Sub cmdRegSrch_Click() 'Reg Number Search
Dim RegSrch As String
RegSrch = txtReg.Text

If RegSrch = "" Then
    MsgBox "You must enter a Registration Number to search for.", vbExclamation, "Data Entry Error"
End If

If rsSearch.BOF <> True Then
    rsSearch.Find "reg ='" & RegSrch & "'", 1, adSearchBackward
    fillfields
End If
If rsSearch.AbsolutePosition < 0 Then
    rsSearch.MoveLast
    rsSearch.Find "reg = '" & RegSrch & "'", SearchDirection:=adSearchBackward
    fillfields
End If
End Sub

Private Sub Form_Unload(Cancel As Integer)
rsSearch.Close
cn.Close
Set rsSearch = Nothing
Set cn = Nothing
End Sub


Any help would be much appreciated.

Thanks
SKM




Edited by - SKM on 12/27/2006 2:10:00 PM

[VB6 DAO] Searching A Database
How do i search a database by using textboxes and seeing if they match certain fields of a record in a database.

I have some text boxes, user enters data in them and if the data in the text boxes matches the data in the database then it will display it. but my next problem is that how would i go about displaying multiple records. i have a control array of labels that are bound to the data control and if what im searching for is in more than one record how would i go about displaying the matching ones? an FAQ or sample code would be very helpful.

Searching Database
Hello gurus:

I have a form with several textboxes on it. I want the user to be able to enter some search text into any one of the boxes and press a button. From here the program will search on this only this field. I don't know how to isolate the text box they are typing in, since it could be any box.
I am planning to use the LIKE command to search.

Any help would be GREATLY appreciated.
___________
CB

Searching Database For 2 Words - Please Help :)
Hey guys-

I'm trying to search my database for 2 words at a time - and I cant figure out how to get it to return the entries that include BOTH words - instead its returning all entries that include the 1st word AND all entries that include the 2nd word...

So, if I type "red hat" into the search bar, it returns any entry that says "red" or any entry that says "hat."

I really have no idea what I'm doing, so any help would be greatly appreciated

This is what I have so far...


Code:
Option Explicit

Private Sub CommandButton1_Click()

Dim rngFind As Range
Dim rngSearch As Range
Dim vntWords As Variant
Dim intWordIndex As Integer

ListBox1.Clear

Set rngSearch = Sheet2.Range("B2", Sheet2.Range("b65536").End(xlUp))
' any match
vntWords = Split(TextBox1.Text, " ")
For Each rngFind In rngSearch
For intWordIndex = LBound(vntWords) To UBound(vntWords)
If Trim(vntWords(intWordIndex)) <> "" Then
If InStr(1, rngFind.Text, vntWords(intWordIndex), vbTextCompare) > 0 Then
ListBox1.AddItem Sheet2.Cells(rngFind.Row, 1).Value
ListBox1.List(ListBox1.ListCount - 1, 1) = rngFind.Address
Exit For
End If
End If
Next
Next


If ListBox1.ListCount = 0 Then
ListBox1.AddItem "No matches..."
End If

End Sub

Private Sub CommandButton2_Click()

Unload Me

End Sub

Private Sub ListBox1_Change()

If ListBox1.ListIndex = -1 Then
TextBox2.Text = ""
Else
If ListBox1.List(ListBox1.ListIndex, 1) <> "" Then
TextBox2.Text = Sheet2.Range(ListBox1.List(ListBox1.ListIndex, 1)).Offset(0, 0)
End If
End If

End Sub

Private Sub ListBox1_Click()

End Sub

Private Sub TextBox1_Change()

End Sub

Private Sub TextBox2_Change()

End Sub

Private Sub UserForm_Click()

End Sub


Private Sub UserForm_Initialize()

ListBox1.ColumnCount = 2
ListBox1.ColumnWidths = ";0"

End Sub

Thank you!!!!
Edit by italkid: Please use the [vb]][ and [/vb] tags to display your code, thanks.

Searching A Large Database
This is going to sould like a very cheezy question but i'm having trouble with it so here we go.

How do I search a database for a specific entry

I don't mean to use a Linear or Binary search, i want to use the search method of the recordset or some minor sql stuff (i know next to no sql so it is the lest bit complex i won't get it )

All i need is to know weather the record exists or not. I don't want to do anything with it.

Problem Searching Database
Hi,

I am trying to do what I thought would be a simple search through a database using a text file as a source for the serach criteria.

Database format is Access 2000
Search criteria is stored in a text file

The following code works and finds the first record ok and addis it to the listbox, but when it loops around to find the next record from the text file it seems to crash (i.e. no evident activity)



Private Sub Command1_Click()
Dim dbs As Database, rst As Recordset
Dim criteria

Set dbs = OpenDatabase("C: empdb1.mdb")
Set rst = dbs.OpenRecordset("customer")

Open "c: empupdate.txt" For Input As #1

Do Until EOF(1)
Input #1, field1
criteria = field1

With rst
.FindFirst !custno = criteria
List1.AddItem !custno & "," & !note
End With

Loop


End Sub



Does anyone have any ideas why this happening.

Thanks

Slim

Searching Database Code Help?
Ok I have this code that goes through my database and picks out all the items that match a certain date and adds them to the list box and it works great. I added another box on my form that does a date compare and puts the difference into a text box like a difference of 15 days. Using this search I want it to be able to check all the people that have that box or record field =>15 and I cant get it too work. it only returns them if they are 15. anywhere I could put could in this to make it work.



Private Sub cmdprint_Click()
'On Error Resume Next
Set db = OpenDatabase(App.Path + "" + "jade.mdb")
lstFind.Clear
If DTPicker1.Value = "" Then
MsgBox "Please enter Date to be searched"
DTPicker1.SetFocus
Exit Sub
End If

Dim City As String
Dim phone As String
Dim FName As String
Dim Class_Dates As String
Dim Search As String
Class_Dates = Trim(UCase(DTPicker1))
Search = "SELECT Class_Dates, LName, FName, phone, City " & _
"FROM Info " & _
"WHERE Class_Dates LIKE '*" & Class_Dates & "*'"

Set rstInfo = db.OpenRecordset(Search)

With rstInfo
If .EOF Then
MsgBox "No matching Jade Participant found, try again please"

Else

Do Until .EOF
lstFind.AddItem .Fields("Class_Dates") & Space(7) & .Fields("phone") & Space(7) & .Fields("LName") & ", " & .Fields("FName") & Space(7) & .Fields("City")
.MoveNext
Loop
End If
End With
End Sub

Adding/Searching DataBase
Hello, I'm having a little trouble getting the database to add and search through. Was wandering if anyone has any idea's on how to get this code working right. And what I'm missing. I have adoc, and the data environment on. The database will load, and I can scroll at the data, and delete data, but not add and search/find. I'm encluding some of the code.
Thank you for any help.

Private Sub Command1_Click()
prompt$ = "To Enter a New Record click OK"
reply = MsgBox(prompt$, vbOKCancel, "Add New Record")
If reply = vbOK Then ' If the user clicks OK
txtText1.SetFocus 'move cursor to Text1 box
DataEnvironment1.rsCommand1.Recordset.AddNew ' and get new record
End If
End Sub

Private Sub Command2_Click()
prompt$ = "Enter the Trouble Ticket Number to start serch"
'get string to be used in the Trouble Ticket field serch
SearchStr$ = InputBox(prompt$, "Ticket Search")
DataEnvironment1.rsCommand1.Index = "Trouble Ticket" 'use Trouble Ticket
DataEnvironment1.rsCommand1.Seek "=", SearchStr$ 'and search
If DataEnvironment1.rsCommand1.NoMatch Then 'if no match
DataEnvironment1.rsCommand1.Recordset.MoveFirst 'go to first record
End If
End Sub

Searching A Phrase In Database
Hi

I tried to implement a search engine where it is possible to split the input into words and search for them considering the options of searching for all the words, any of the words or as a phrase.

I managed to code the part for searching all and any of the words but the part for searching for a phrase doesn't seem to work...

For splitting the input I used (that is being used for searching word by word):

retString1 = Split(txtInput.Text, " ")

and for joining to search as a phrase I used:

strDisplay = Join(retString1)
SQL = SQL & " Author LIKE '%strDisplay%'"


I believe there is something wrong with '%strDisplay% part of it.

Any ideas?

Thanks

Copyright © 2005-08 www.BigResource.com, All rights reserved