|
-
Dec 24th, 2003, 10:21 AM
#1
Thread Starter
New Member
Searching dataset
Hi! I need to pass search results and reload the form. What's the best way to do it? The code for search routine is below:
----------------------------------------------------
Dim count, i, pos As Integer
Dim s As String
s = InputBox("Enter in search criteriar:", "Search")
If s = "" Then
Else
count = 0
Do Until (count = Me.BindingContext(objBDB, "PDDBdbReport_View").Count)
If objBDB.PDDBdbReport_View.Rows(count).Item("ProjectNumber") = s Then
pos = Me.BindingContext(objBDB, "PDDBdbReport_View").Position
End If
count = count + 1
Loop
If pos > 0 Then
Me.BindingContext(objBDB, "PDDBdbReport_View").Position = pos
Else
MsgBox("Unable to find search.", MsgBoxStyle.OKOnly, "Not found")
End If
End If
-
Dec 25th, 2003, 11:36 PM
#2
Frenzied Member
In your code you are just searching for a string and see how many matches there are, and then move the position to the very last one of them. But is that what you mean by search?
In a simple way you can bind your form to a dataview object and filter that dataview based on the criteria you provide.
Also: It's not a good practice to leave an empty condition in my opinion. So instead of:
VB Code:
If s = "" Then
Else
count = 0
Do Until (count = Me.BindingContext(objBDB, "PDDBdbReport_View").Count)
If objBDB.PDDBdbReport_View.Rows(count).Item("ProjectNumber") = s Then
pos = Me.BindingContext(objBDB, "PDDBdbReport_View").Position
End If
count = count + 1
Loop
If pos > 0 Then
Me.BindingContext(objBDB, "PDDBdbReport_View").Position = pos
Else
MsgBox("Unable to find search.", MsgBoxStyle.OKOnly, "Not found")
End If
End If
You better rephrase it in this way:
VB Code:
If s <> "" Then
count = 0
Do Until (count = Me.BindingContext(objBDB, "PDDBdbReport_View").Count)
If objBDB.PDDBdbReport_View.Rows(count).Item("ProjectNumber") = s Then
pos = Me.BindingContext(objBDB, "PDDBdbReport_View").Position
End If
count = count + 1
Loop
If pos > 0 Then
Me.BindingContext(objBDB, "PDDBdbReport_View").Position = pos
Else
MessageBox.Show("Unable to find search.", "Not found", MessageBoxButtons.OK)
End If
End If
'Heading for the automatic overload'
Marillion, Brave, The Great Escape, 1994
'How will WE stand the FIRE TOMORROW?'
Eloy, Silent Cries and Mighty Echoes, The Vision - Burning, 1979
-
Dec 26th, 2003, 11:20 AM
#3
Thread Starter
New Member
Display results?
Thank you! How to display results on the form?
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
|