Hi
I am still facing problems after writing the codes for finding a record. A compile error occurs, which says
"User-defined type not defined" .I don't understand what it means or even how to go about it. please i need help.The following are the codes i wrote for the program;
Option Explicit
Dim db As Database
Dim rs As Recordset
Private Sub cmdsearch_Click()
If Trim(txtsearch.Text) <> "" Then
Set rs = db.OpenRecordset("select * from details where id='" & Trim(txtsearch.Text) & "'")
If rs.RecordCount > 0 Then
txtid.Text = rs!id
txtname.Text = rs!Name
txtbasic.Text = rs!basic
txtsearch.SelStart = 0
txtsearch.SelLength = Len(Trim(txtsearch.Text))
txtsearch.SetFocus
Else
MsgBox "Sorry, there is no such record found in the database with Employee ID :" & _
Trim(txtsearch.Text) & "." & vbCrLf & "Please try again...", vbExclamation, "Employee"
txtid.Text = ""
txtname.Text = ""
txtbasic.Text = ""
txtsearch.SelStart = 0
txtsearch.SelLength = Len(Trim(txtsearch.Text))
txtsearch.SetFocus
End If
Else
MsgBox "Please mention the employee id to search for.", vbExclamation, "Employee"
txtsearch.SetFocus
End If
End Sub
Private Sub Form_Load()
Set db = OpenDatabase(App.Path & "\employee.mdb")
Set rs = db.OpenRecordset("details", dbOpenTable)
If rs.RecordCount > 0 Then
rs.MoveFirst
Else
MsgBox "Please add some records to the database before you try to search.", vbInformation, "Employee"
End If
End Sub