by Goshen M. Jimenez (1 Submission)
Category: Databases/Data Access/DAO/ADO
Compatability: Visual Basic 5.0
Difficulty: Unknown Difficulty
Originally Published: Mon 8th July 2002
Date Added: Mon 8th February 2021
Rating: (1 Votes)
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
' 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
No comments have been posted about Functionalize Your Dbase Connections Retrieve data and edit it as you wish when the record is put i. Why not be the first to post a comment about Functionalize Your Dbase Connections Retrieve data and edit it as you wish when the record is put i.