Hi Guys,
Have been handed a working project and have very little understanding of how it works (Im an asp web person)
Can someone please help me with the following.
When a user searches for a Surname in this program, if the Surname is not found it returns an error of:
"Run-time error '3021'
Method 'Value' of object 'Field' Failed"
I understand this is because the program still thinks it is returning results, but there is none to return.
The code is:
Private Sub cmdFind_Click()
' Remove previously saved bookmark from collection
If (DataGrid1.SelBookmarks.Count <> 0) Then
DataGrid1.SelBookmarks.Remove 0
End If
' Prompt user for last name
FindLastName = InputBox("Please enter the students's surname you want to search for", "Find"
If StrPtr(FindLastName) = 0 Then
' If clicked cancel, then exit
Else
If Len(FindLastName) = 0 Then
' If nothing entered, then exit
Else
DataEnvironment1.rsDataTable.Find "surname = '" & FindLastName & "'", , , 1
' Append your bookmark to the collection of selected rows
DataGrid1.SelBookmarks.Add DataEnvironment1.rsDataTable.Bookmark
End If 'Len(FindLastName)
End If 'StrPtr
End Sub
I don't know where to add the .. If BOF AND EOF stuff to display "No records".. Can someone help me?
Is their more code I should paste? (And generally where would i find it?)
Also, my second question is, the program stops when it finds a match. How can I enable a message that allows the user to "Find Next Match"?
Thanks in advance!
BatGrrrL
Sorry for being so vague, today is my first day with VB.
Have been handed a working project and have very little understanding of how it works (Im an asp web person)
Can someone please help me with the following.
When a user searches for a Surname in this program, if the Surname is not found it returns an error of:
"Run-time error '3021'
Method 'Value' of object 'Field' Failed"
I understand this is because the program still thinks it is returning results, but there is none to return.
The code is:
Private Sub cmdFind_Click()
' Remove previously saved bookmark from collection
If (DataGrid1.SelBookmarks.Count <> 0) Then
DataGrid1.SelBookmarks.Remove 0
End If
' Prompt user for last name
FindLastName = InputBox("Please enter the students's surname you want to search for", "Find"
If StrPtr(FindLastName) = 0 Then
' If clicked cancel, then exit
Else
If Len(FindLastName) = 0 Then
' If nothing entered, then exit
Else
DataEnvironment1.rsDataTable.Find "surname = '" & FindLastName & "'", , , 1
' Append your bookmark to the collection of selected rows
DataGrid1.SelBookmarks.Add DataEnvironment1.rsDataTable.Bookmark
End If 'Len(FindLastName)
End If 'StrPtr
End Sub
I don't know where to add the .. If BOF AND EOF stuff to display "No records".. Can someone help me?
Is their more code I should paste? (And generally where would i find it?)
Also, my second question is, the program stops when it finds a match. How can I enable a message that allows the user to "Find Next Match"?
Thanks in advance!
BatGrrrL
Sorry for being so vague, today is my first day with VB.