i put a search on my program and i use SQL. I want my search function to search even just the part of the string in my access database. how would i do that? - Private Sub Form_Load()
-
-
Dim rsData As ADODB.Recordset
-
-
' load the database
-
Set DBConn = LoadDatabase(App.Path & "\dbase\dbmain.mdb")
-
-
ListEmployees
-
Me.Timer2.Enabled = False
-
End Sub
-
-
Private Sub Form_Resize()
-
Me.proOne.Width = Me.ScaleWidth - 9100
-
Me.txtSearch.Width = Me.ScaleWidth - (Me.txtSearch.Left * 20)
-
Me.lstMaster.Width = Me.ScaleWidth - (Me.lstMaster.Left * 2)
-
Me.lstMaster.Height = Me.ScaleHeight - 1600
-
End Sub
-
-
-
-
Private Sub lstMaster_DblClick()
-
If Not (Me.lstMaster.SelectedItem Is Nothing) Then
-
frmNew.txtID.Text = Me.lstMaster.SelectedItem.SubItems(0)
-
frmNew.txtFName.Text = Me.lstMaster.SelectedItem.SubItems(1)
-
frmNew.cboPosition.Text = Me.lstMaster.SelectedItem.SubItems(2)
-
frmNew.txtStatus.Text = Me.lstMaster.SelectedItem.SubItems(3)
-
frmNew.txtRate.Text = Me.lstMaster.SelectedItem.SubItems(4)
-
frmNew.dtpStart.value = Me.lstMaster.SelectedItem.SubItems(5)
-
frmNew.dtpEnd.value = Me.lstMaster.SelectedItem.SubItems(6)
-
frmNew.txtAge.Text = Me.lstMaster.SelectedItem.SubItems(7)
-
frmNew.txtAddress.Text = Me.lstMaster.SelectedItem.SubItems(8)
-
-
frmNew.cmdUpdate.Caption = "&Update"
-
-
frmNew.Show
-
Unload Me
-
End If
-
End Sub
-
-
Private Sub mnuExit_Click()
-
frmMain.Show
-
Unload Me
-
End Sub
-
-
Private Sub mnuManageUsers_Click()
-
frmManageUsers.Show
-
Unload Me
-
End Sub
-
-
Private Sub mnuNew_Click()
-
frmNew.Show
-
Unload Me
-
End Sub
-
-
Private Sub Timer1_Timer()
-
If Me.proOne.value = "100" Then
-
Call SearchAll
-
Me.Timer1.Enabled = False
-
Me.Timer2.Enabled = True
-
Else
-
Me.proOne.value = Me.proOne.value + Val(1)
-
End If
-
End Sub
-
-
Private Sub Timer2_Timer()
-
If Me.Label1.Visible = True Then
-
Me.Label1.Visible = False
-
ElseIf Me.Label1.Visible = False Then
-
Me.Label1.Visible = True
-
End If
-
End Sub
-
-
Private Sub txtSearch_Click()
-
Me.txtSearch.Text = ""
-
Me.Timer2.Enabled = False
-
End Sub
-
-
Private Sub txtSearch_GotFocus()
-
Me.txtSearch.Text = ""
-
End Sub
-
-
Private Sub ListEmployees()
-
Set rsData = DBConn.Execute("SELECT EmpID, EmpName, EmpPosition, EmpStatus, EmpRate, DateHired, Endo, EmpAge, EmpAddress FROM tblMasterData")
-
-
Me.lstMaster.ListItems.Clear
-
If rsData.RecordCount > 0 Then
-
rsData.MoveFirst
-
-
Do Until rsData.EOF Or rsData.BOF
-
With Me.lstMaster.ListItems.Add(, , rsData("EmpID").value & "")
-
.SubItems(1) = rsData("EmpName").value & ""
-
.SubItems(2) = rsData("EmpPosition").value & ""
-
.SubItems(3) = rsData("EmpStatus").value & ""
-
.SubItems(4) = rsData("EmpRate").value & ""
-
.SubItems(5) = rsData("DateHired").value & ""
-
.SubItems(6) = rsData("Endo").value & ""
-
.SubItems(7) = rsData("EmpAge").value & ""
-
.SubItems(8) = rsData("EmpAddress").value & ""
-
End With
-
rsData.MoveNext
-
Loop
-
End If
-
End Sub
-
-
Private Sub txtSearch_KeyPress(KeyAscii As Integer)
-
If KeyAscii = 13 Then
-
If Me.txtSearch.Text <> "" Then
-
Me.proOne.Visible = True
-
Me.proOne.value = 0
-
Me.Timer1.Enabled = True
-
Me.Timer2.Interval = 400
-
Else
-
Me.Label1.Caption = "Type in a name to search."
-
Me.Label1.ForeColor = vbRed
-
Me.txtSearch.SetFocus
-
End If
-
End If
-
End Sub
-
-
Private Sub SearchAll()
-
Set rsData = DBConn.Execute("SELECT * FROM tblMasterData WHERE EmpName = '" & Me.txtSearch.Text & "'")
-
-
Me.lstMaster.ListItems.Clear
-
If rsData.RecordCount > 0 Then
-
rsData.MoveFirst
-
-
Do Until rsData.EOF Or rsData.BOF
-
With Me.lstMaster.ListItems.Add(, , rsData("EmpID").value & "")
-
.SubItems(1) = rsData("EmpName").value & ""
-
.SubItems(2) = rsData("EmpPosition").value & ""
-
.SubItems(3) = rsData("EmpStatus").value & ""
-
.SubItems(4) = rsData("EmpRate").value & ""
-
.SubItems(5) = rsData("DateHired").value & ""
-
.SubItems(6) = rsData("Endo").value & ""
-
.SubItems(7) = rsData("EmpAge").value & ""
-
.SubItems(8) = rsData("EmpAddress").value & ""
-
End With
-
Me.Label1.Caption = "Found Existing Record(s)."
-
rsData.MoveNext
-
Loop
-
Else
-
Me.Label1.Caption = "No Record(s) Found!"
-
End If
-
End Sub
-
the problem is that it searches for the whole match of the string. i want it to be like this
the field contains john Castro, Robert So, Rick Williams ....
and if i type "john" it will display all records with the word "john".
please help me with.
much appreciated.
The exact syntax and wildcards depend on the DBMS that you're using. - SELECT *
-
FROM SomeTable
-
WHERE SomeField LIKE '%hello%'
6 2007
Instead of the = operator, use the like operator with wildcards.
That "LIKE" thing, is that something like this; - Set rsData = DBConn.Execute("SELECT * FROM tblMasterData WHERE EmpName LIKE '" & Me.txtSearch.Text & "'")
Sir i'm sorry to admit that i'm new with these SQL lines.
Culd you give me some example please?
The exact syntax and wildcards depend on the DBMS that you're using. - SELECT *
-
FROM SomeTable
-
WHERE SomeField LIKE '%hello%'
In my program, the user will input his/her query in a txtbox, so how would I going to replace that '%hello%' with my txtbox like '"%me.txtFName.txt%"'?
Sir here is what I did but still don't know if it's correct. - Set rsData = DBConn.Execute("SELECT * FROM tblMasterData WHERE EmpName LIKE" & "*" & Val(Me.txtSearch.Text) & "*")
You do it the same way you have it in your original code. Except now you're using Like and wildcards as part of the string.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: M |
last post by:
Hi,
I've searched through the previous posts and there seems to be a few
examples of search and replacing all occurrances of a string with
another string.
I would have thought that the code...
|
by: AMT2K5 |
last post by:
Hello,
I have an assignment to do in class which requires me to create a
single line editor not a multi-line editor.
I am confused about what this means, I would appreciate any
clarification....
|
by: Jozef Jarosciak |
last post by:
Quickest way to find the string in 1 dimensional string array!
I have a queue 1 dimensional array of strings called 'queue' and I need
a fast way to search it. Once there is match, I don't need...
|
by: vinayg |
last post by:
how can i search subcategory wise for a particular category,i want to display items.suppose user selected a particular category.I want to display all items in that category + its subcategories.
...
|
by: daisies |
last post by:
Hi Everyone,
I'm new to java and to web development.
I need to know how to display items of an arraylist in a h:datatable to look like this:
----------------------------
| item1 | item2 |...
|
by: Jeremy Kitchen |
last post by:
Are there any library functions that can help me to do this? If
necessary I can convert the string to a byte array. I don't want to
have to write my own Hex conversion if it isn't necessary.
...
|
by: yu_kuo |
last post by:
Is there any comparison data on perfomance difference between
std::string and c style string? Or maybe if there are source code
which could be used to measuer on different compiler/platform, in a...
|
by: Xcriber51 |
last post by:
Hi --
I'm not entirely familiar with the norms and standard libraries of
JavaScript so if the answer to this is yesterday's news, please ignore.
I'm trying to write a simple text formatting...
|
by: anoop s |
last post by:
Hi,
How to display items of completion list of ajax autocompleteextender one at a row. Now it is displaying two or three according to the size of items in a row.
thanks
|
by: phpuser123 |
last post by:
I want to display my string str as the defaultinput value and when I run ,oly the first part of the word is displayed. It skips everything after the blank space.How do I sort this out?
<%
...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome former...
|
by: ryjfgjl |
last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
| |