Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Runtime error 3426

Status
Not open for further replies.

btriggs127

Technical User
Dec 1, 2000
16
US
I need some assistance in debugging this app I created in a student verision of VB6. The app has a command button that needs to search an Access database for records by 1 of 3 text fields that the user puts the search critia in. At this point the only thing I get when I click on the find command button is an Error 3426. the code is as follows:

Private Sub cmdFind_Click()

Dim strSearch As String, fieval As String, foundflag As Boolean

If Not Text1(1).Text = "" Then
strSearch = UCase(Text1(1).Text)
fieval = ("ID Number")
Else
If Not Text1(2).Text = "" Then
strSearch = UCase(Text1(2).Text)
fieval = ("Last Name")
Else
strSearch = UCase(Text1(3).Text)
fieval = ("First Name, Middle Initial")
End If
End If

If Len(strSearch) > 0 Then

datData1.Recordset.MoveFirst
foundflag = False
Do While (Not foundflag) And (Not datData1.Recordset.EOF)
If UCase(datData1.Recordset.Fields(fieval).Value) = strSearch Then
foundflag = True
Text1(1).Text = datData1.Recordset.Fields("ID Number").Value
Text1(2).Text = datData1.Recordset.Fields("Last Name").Value
Text1(3).Text = datData1.Recordset.Fields("First Name, Middle Initial").Value
Else
datData1.Recordset.MoveNext
End If
Loop
If Not foundflag Then
MsgBox "Not found", , "Not Found"
datData1.Recordset.MoveLast
End If
End If

end sub

Any assistance is greatly appericiated.

Thanks
Brian
 
That works for adding a new record. But, I need to search the records for specific records in a database by choosing 1 of the fields and returning the rest of the data for that record. Like looking for a person by either ID, Last name, or first name.
 
It's probably more efficient to use a SQL query to search the database, then use the recordset returned from the query for your output.
I suggest you look up ADO and SQL on this forum, in VBHelp and on MSDN to get started. Let me know if this helps
________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first

'People who live in windowed environments shouldn't cast pointers.'
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top