|
-
June 2nd, 2009, 05:27 AM
#1
Search Tool
Hallo,
This search button works fine, however, in the tooltip it shows "Record Found" as highlighted in the code below. What I want to do is to say how many records have been found. Lets say 2 records found it says "2 Records Found". I understand a count function must be included please could anyone update the code for me to accomodate that functionality.
Thank you very much indeed. Please find the code below;
Code:
Private Sub btnPerformSearch_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPerformSearch.Click
' Declare local variables...
Dim intPosition As Integer
' Determine the appropriate item selected and set the
' Sort property of the DataView object...
Select Case cboField.SelectedIndex
Case 0 'PRACTICE
objDataView.Sort = "PRACTICE"
Case 1 'HEALTH AUTHORITY
objDataView.Sort = "HA_NAME"
Case 2 'REGION
objDataView.Sort = "REGION"
Case 3 'TOWN
objDataView.Sort = "TOWN"
Case 4 'POSTCODE
objDataView.Sort = "POSTCODE"
Case 5 'CLINCOMP
objDataView.Sort = "CLINCOMP"
Case 6 'GPRDSTATUS
objDataView.Sort = "GPRDSTATUS"
End Select
' If the search field is not price then...
If cboField.SelectedIndex < 7 Then
' Find the practice details
intPosition = objDataView.Find(txtSearchCriteria.Text)
End If
If intPosition = -1 Then
' Display a message that the record was not found...
ToolStripStatusLabel1.Text = "Record Not Found"
Else
' Otherwise display a message that the record was
' found and reposition the CurrencyManager to that
' record...
ToolStripStatusLabel1.Text = "Record Found"
objCurrencyManager.Position = intPosition
End If
' Show the current record position...
ShowPosition()
End Sub
Last edited by HanneSThEGreaT; June 2nd, 2009 at 09:28 AM.
-
June 2nd, 2009, 09:32 AM
#2
Re: Search Tool
Would something like this :
Code:
ToolStripStatusLabel1.Text = objDataView.Count & " Record(s) Found"
Work ¿
-
July 14th, 2009, 04:41 AM
#3
Count Function
Hallo,
I have th efollowing search code which works fine. However, I have an additional task to do, which is create a count funtion for the Record found or Record not found. Presently what it does is it searchs and if a record is found it displays at the tooltip "Record Found" if not it says "Record Not found". However, sometimes you have 2 or more records. Therefore, the tooltip should say the exact amount of records found.. For example, 3 Records Found or even 5 Records Found.
Also if only one record is found it says "Record Found" but if more it should display " 2 Records Found".
Please could anyone help me with the count syntax to be added to the code.. Thanks
Code:
Private Sub btnPerformSearch_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPerformSearch.Click
' Declare local variables...
Dim intPosition As Integer
' Determine the appropriate item selected and set the
' Sort property of the DataView object...
Select Case cboField.SelectedIndex
Case 0 'PRACTICE
objDataView.Sort = "PRACTICE"
Case 1 'HEALTH AUTHORITY
objDataView.Sort = "HA_NAME"
Case 2 'REGION
objDataView.Sort = "REGION"
Case 3 'TOWN
objDataView.Sort = "TOWN"
Case 4 'POSTCODE
objDataView.Sort = "POSTCODE"
Case 5 'CLINCOMP
objDataView.Sort = "CLINCOMP"
Case 6 'GPRDSTATUS
objDataView.Sort = "GPRDSTATUS"
End Select
' If the search field is not price then...
If cboField.SelectedIndex < 7 Then
' Find the practice details
intPosition = objDataView.Find(txtSearchCriteria.Text)
End If
If intPosition = -1 Then
' Display a message that the record was not found...
ToolStripStatusLabel1.ForeColor = Color.Red
ToolStripStatusLabel1.Font = New Font(Font, FontStyle.Bold)
ToolStripStatusLabel1.Text = "Record Not Found"
Else
' Otherwise display a message that the record was
' found and reposition the CurrencyManager to that
' record...
ToolStripStatusLabel1.ForeColor = Color.Red
ToolStripStatusLabel1.Font = New Font(Font, FontStyle.Bold)
ToolStripStatusLabel1.Text = "Record Found"
objCurrencyManager.Position = intPosition
End If
' Show the current record position...
ShowPosition()
Me.QryContactsperpracTableAdapter1.FillBy(Me.QryContacts1.QryContactsperprac, TxtPracName.Text, TxtPostcode.Text, TxtSite.Text, TxtAddress1.Text)
End Sub
Last edited by HanneSThEGreaT; July 14th, 2009 at 06:35 AM.
Reason: Code Tags!
-
July 14th, 2009, 06:34 AM
#4
Re: Count Function
What's was wrong with this answer ¿ :
http://www.codeguru.com/forum/showthread.php?t=478239
Couldn't you manage to get it to work ¿
-
July 14th, 2009, 07:38 AM
#5
Re: Search Tool
This code did not work...
It displayed the number of all records on the tooltip
as
9134 Record(s) Found
This was shown even if ONLY 2 records were present...
any help!!!
Thanks for the suggestion
-
July 14th, 2009, 07:46 AM
#6
Re: Count Function
This code did not work...
It displayed the number of all records on the tooltip
as
9134 Record(s) Found
This was shown even if ONLY 2 records were present...
any help!!!
Thanks for the suggestion
-
July 14th, 2009, 08:10 AM
#7
-
July 14th, 2009, 09:04 AM
#8
Re: Search Tool
The problem is it doesn't show the number of records obtained..
I want it to tell the user if the number of records are 2, 10, 1000 etc
Therefore it should look like, for example - 2 Record(s) Found or 1000 Record(s) Found
any ideas
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|