Functionalize Your Dbase Connections Retrieve data and edit it as you wish when the record is put i
Functionalize Your Dbase Connections Retrieve data and edit it as you wish when the record is put in variable, Easy Check if the record exists
API Declarations
Global Dbase as Database ' Your Database
Global SearchIn as String ' Sets the table where the SearchFor is to be searched
Global SearchFor as String ' Sets the String you are Searching for in the database
Rate Functionalize Your Dbase Connections Retrieve data and edit it as you wish when the record is put i
(1(1 Vote))
' Be sure to check Microsoft DAO as a reference
Function Search () as Boolean
Search = True
Set Dbase = OpenDatabase(" Path/ DbName ")
Select Case SearchIn
Case "Student"
Set MyRecord = dbase.openrecordset("Select * From tblStudents where fldStudentNo = " & chr(34) & SearchFor & chr(34))
Case "Instructor"
Set Myrecord = dbase.openrecordset("Select * From tblInstructors where fldInstructorCode = " & chr(34) & SearchFor & chr(34))
Case "Subject"
Set Myrecord = dbase.openrecordset("Select * From tblInstructors where fldInstructorCode = " & chr(34) & SearchFor & chr(34))
End Select
If MyRecord.BOF = True then Search =False
End Function
'
'To Call the function, simply put this on a keypress or OnClick of a button or textbox
'
'
'
Private Sub CmdBtnFIND_Click()
SearchFor = Text1.text ' The textbox where the user inputs the ID
SearchIn = (Either "Student", "Instructor" or "Subject")
If Search = False then
MsgBox " No Such Record in Database"
Exit Sub
Else
MsgBox "Record Found"
' Then you can do what you please with the data in MyRecord
' To Add say "Myrecord.Addnew"
' To Edit say "Myrecord.Edit"
' To Save say "Myrecord.Update"
' To Delete say "Myrecord.Delete"
End if
End Sub
' Enjoy
Functionalize Your Dbase Connections Retrieve data and edit it as you wish when the record is put i Comments
No comments yet — be the first to post one!
Post a Comment