Data
002 Public Class Loan
003 Dim inc As Integer
004 Dim MaxRows AsInteger
005 Dim ds As NewDataSet
006 Dim da AsOleDb.OleDbDataAdapter
007 Dim sql As String
008 ' Dim cb As New OleDb.OleDbCommandBuilder(da)
009
01 Private Subbtnload_Click(ByValsender As System.Object, ByVal e AsSystem.
0 EventArgs) Handles btnload.Click
011 Dim con As NewOleDb.OleDbConnection
012
013
con.ConnectionString = "PROVIDER=Microsoft.Jet.OLEDB.4.0;Data
014
Source = C:\Documents and Settings\Family\Desktop\K_S.mdb"
015 con.Open()
016 sql = "SELECT * FROM tblLoan"
017 da = NewOleDb.OleDbDataAdapter(sql, con)
018 da.Fill(ds, "k_S")
019
020
021 con.Close()
022
023
024 MaxRows = ds.Tables("K_S").Rows.Count
025 inc = -1
026
027 End Sub
028 Private SubNavigateRecords()
029
030 txtisbn.Text = ds.Tables("K_S").Rows(inc).Item(1)
031 txtloancardnumber.Text = ds.Tables("K_S").Rows(inc).Item(2)
032 txtloandate.Text = ds.Tables("K_S").Rows(inc).Item(3)
033 txtreturndate.Text = ds.Tables("K_S").Rows(inc).Item(4)
034 chkonloan.Text = ds.Tables("K_S").Rows(inc).Item(5)
035 End Sub
036
037
03 Private SubbtnNext_Click(ByValsender As System.Object, ByVal e AsSystem.
8 EventArgs) Handles btnNext.Click
039 If inc <> MaxRows - 1 Then
040 inc = inc + 1
041 NavigateRecords()
042 Else
043 MsgBox("No More Rows")
044 End If
045 End Sub
046
04 Private SubbtnPrevious_Click(ByValsender As System.Object, ByVal e AsSys
7 tem.EventArgs) HandlesbtnPrevious.Click
048 If inc > 0 Then
049 inc = inc - 1
050 NavigateRecords()
051 ElseIf inc = -1 Then
052 MsgBox("No Records Yet")
053 ElseIf inc = 0 Then
054 MsgBox("First Record")
055 End If
056 End Sub
057
05 Private SubbtnFirst_Click(ByValsender As System.Object, ByVal e AsSystem
8 .EventArgs) Handles btnFirst.Click
059 If inc <> 0 Then
060 inc = 0
061 NavigateRecords()
062 End If
063 End Sub
064
06 Private SubbtnLast_Click(ByValsender As System.Object, ByVal e AsSystem.
5 EventArgs) Handles btnLast.Click
066 If inc <> MaxRows - 1 Then
067 inc = MaxRows - 1
068 NavigateRecords()
069 End If
070 End Sub
071
07 Private Subbtnadd_Click(ByValsender As System.Object, ByVal e AsSystem.E
2 ventArgs) Handles btnaddnew.Click
073 btnCommit.Enabled = True
074 btnAddNew.Enabled = False
075 btnUpdate.Enabled = False
076 btndelete.Enabled = False
077
078 txtisbn.Clear()
079 txtloancardnumber.Clear()
080 txtloandate.Clear()
081 txtreturndate.Clear()
082 End Sub
083
08 Private SubbtnClaear_Click(ByValsender As System.Object, ByVal e AsSyste
4 m.EventArgs) Handles btnClear.Click
085 btnCommit.Enabled = False
086 btnaddnew.Enabled = True
087 btnUpdate.Enabled = True
088 btndelete.Enabled = True
089
090 inc = 0
091 NavigateRecords()
092 End Sub
093
09 Private SubbtnCommit_Click(ByValsender As System.Object, ByVal e AsSyste
4 m.EventArgs) Handles btnCommit.Click
095 If inc <> -1 Then
096
097 Dim cb As NewOleDb.OleDbCommandBuilder(da)
098 Dim dsNewRow As DataRow
099
100 dsNewRow = ds.Tables("AddressBook").NewRow()
101
102 dsNewRow.Item("ISBN") = txtisbn.Text
103 dsNewRow.Item("Loan Card Number") = txtloancardnumber.Text
104 dsNewRow.Item("Loan Date") = txtloandate.Text
105 dsNewRow.Item("REturn Date") = txtreturndate.Text
106
107
108 ds.Tables("K_S").Rows.Add(dsNewRow)
109
110 da.Update(ds, "K_S")
111
112 MsgBox("New Record added to the Database")
113
114 btnCommit.Enabled = False
115 btnaddnew.Enabled = True
116 btnUpdate.Enabled = True
117 btndelete.Enabled = True
118
119 End If
120 End Sub
121
12 Private SubbtnUpdate_Click(ByValsender As System.Object, ByVal e AsSyste
2 m.EventArgs) Handles btnUpdate.Click
123 Dim cb As NewOleDb.OleDbCommandBuilder(da)
124 ds.Tables("K_S").Rows(inc).Item(1) = txtisbn.Text
125 ds.Tables("K_Sk").Rows(inc).Item(2) = txtloancardnumber.Text
126 ds.Tables("K_S").Rows(inc).Item(3) = txtloandate.Text
127 ds.Tables("K_S").Rows(inc).Item(4) = txtreturndate.Text
128 ' da.Update(ds, "AddressBook")
129 MsgBox("Data updated")
130 End Sub
131
13 Private Subbtndelete_Click(ByValsender As System.Object, ByVal e AsSyste
2 m.EventArgs) Handles btndelete.Click
IfMessageBox.Show("Do you really want to Delete this
133
Record?", "Delete", MessageBoxButtons.YesNo, _
134 MessageBoxIcon.Warning) = DialogResult.No Then
135
136
137 MsgBox("Operation Cancelled")
138 Exit Sub
139
140 End If
141 Dim cb As NewOleDb.OleDbCommandBuilder(da)
142
143 ds.Tables("K_S").Rows(inc).Delete()
144 MaxRows = MaxRows - 1
145
146 inc = 0
147 NavigateRecords()
148 da.Update(ds, "K_S")
149 End Sub
150 End Class
Library Management System using VB 6 with MS Access
Database
posted by Girish Sundaram on December 25, 2016
In this post, we want to develop a Library Management System in Visual Basic 6.
1. frmLibraryManagement
2. frmLogin
3. frmBookdetails
4. frmMemberdetails
5. frmMenu
6. Module1.bas
System Design
LIBRARY MANAGEMENT SYSTEM
Now we need to convert the E-R Model to a Relational Model which means create table
BOOK TABLE
The book table in Access Design View is given below. One of the Field Name is "Primary
BOOK TABLE
LOGIN TABLE
The login table in MS Access Design View is given below. The Field Name "User ID" is
LOGIN TABLE
MEMBER TABLE
The third table in MS Access Design View is given below. The Field Name "Member ID"
MEMBER TABLE
RELATIONSHIP
To view or create relationships among tables, go to Database Tool from the Toolbar
You can design the interface for each of the forms in Visual Basic now. However, you
Labels
Name : lblLibraryManagement
Name : cmdLogin
Caption : LOGIN
End Sub
The log in screen is different because you want password to be hidden when you type
[Right-Click] Project1.vbp > Select Add > [Click] Form. The new form dialog
FORM LOG IN
Labels
Name : lblUserID
Caption: Password
Text-Boxes
Name : txtUserID
Name : txtPassword
Buttons
Name : cmdOK
Caption: Login
Name : cmdCancel
Caption: Cancel
Option Explicit
Exit Sub
Else
MsgBox "Invalid Password, try again!", , "Login"
txtPassword.SetFocus
SendKeys "{Home}+{End}"
End If
End If
rs.MoveNext
Wend
End Sub
Call loadcon
MsgBox ("Connected")
End Sub
The frmMenu is a form with menu items and we can create a menu using Menu Editor.
To create a MDI form, [Right-Click] Project1.vbp > Select Add > [Click] MDI
Form.
form. The other form that must open within MDI form should have their MDI child
The frmBookDetails store the book information and you can perform various operations
Labels
Name : lblBookDetails
Name : lblBookID
Caption : BOOK ID
Name : lblBookname
Caption : AUTHOR
Name : lblMID
Caption : MEMBER ID
Text-Boxes
Name : txtBookID
Name : txtBookname
Name : txtAuthor
Name : txtMID
Buttons
Name : cmdAdd
Caption : &ADD
Name : cmdDel
Caption : &DELETE
Name : cmdUpdate
Caption : &UPDATE
Name : cmdDisplay
Caption : &DISPLAY
Name : cmdClear
Caption : &CLEAR
Name : cmdExit
Caption : &EXIT
Data Grids
Name : DataGrid1
con.Execute "DELETE * FROM BOOK WHERE BookID = " & txtBookID & ""
MsgBox ("Record Deleted !!")
End Sub
Set DataGrid1.DataSource = rs
End Sub
End Sub
End Sub
End Sub
Labels
Name : lblMemberDetai
Name : lblMID
Caption : MEMBER ID
Name : lblMembername
Text-Boxes
Name : txtMemberID
Name : txtMembername
Buttons
Name : cmdAdd
Caption : &ADD
Name : cmdDel
Caption : &DELETE
Name : cmdUpdate
Caption : &UPDATE
Name : cmdDisplay
Caption : &DISPLAY
Name : cmdClear
Caption : &CLEAR
Name : cmdExit
Caption : &EXIT
Data Grids
Name : DataGrid1
End Sub
End Sub
Private Sub cmdDisplay_Click()
rs.CursorLocation = adUseClient
rs.CursorType = adOpenStatic
End Sub
End Sub
Module1.bas
All form need to connect to Microsoft Access Database but you may have to write the
code for connection in each form. It there is a large number of forms in the project, say
con.Open constr
End Sub
Note: You cannot add the code for Module 1 because first you have to add the
components for Microsoft ADO Data Control 6.0 (OLEDB) and Microsoft Data
For my project in IT419 Database Management System, I created the Library Management System
software. The software is implemented using Microsoft Access 2007 with Visual Basic for Application for
its User Interface and automation. This software can be used in a small school library. With a slight
modification, it can also be used in a book borrowing store. In my project, Ive chosen the University
Library of UP Diliman to be my fictitious software client mainly because of its nice logo which fits nicely on
my user interface design.
The first form that will display when using this program is the Main Form. From here, the user can select 7
menus:
accounts
Reports allows user (the librarian) to view the different Library reports.
B. THE LOGIN SYSTEM
Using the login menu, the user can access features of the software by providing username and password.
The user can access the software as either a Librarian or as a Patron.
ANONYMOUS MODE This mode is activated during startup when users are not yet logged in.
PATRON MODE This mode is activated when a Library patron is logged in.
LIBRARIAN MODE This mode is activated when a Librarian is logged in.
C. SEARCH SYSTEM
In this menu, the user can search for a particular library item based on selected search criteria and search
text:
The search results will display every item that matched the search text. It also allows you to view the
specific details of the library item by clicking on the corresponding details button.
When the Details button is clicked, the Library Item Details Form will show, displaying the particular items
details.
CHECK-IN FORM
This form is accessible only by a Librarian account and is used when patrons return the borrowed books.
The returned items ID and copy number can be selected and any fines incurred will be automatically
calculated by the software.
CHECK-OUT FORM
This form is accessible only by a Librarian account and is used when patrons borrow books. In order for
the Library Item to be borrowed, the borrowers name and borrowed items ID and index number are
specified. The Due date is automatically calculated by the software based on the Circulation Type of the
borrowed item.
E. ADMINISTRATION SYSTEM
This form is accessible only by a Librarian account. In this form, the librarian can add, edit, and delete
librarian accounts and librarian groups. The librarian can also add, edit and delete patron accounts and
patron groups.
ITEM MANAGEMENT FORM
This form is accessible only by a Librarian account. In this form, the librarian can add, edit, and delete
item author, publisher, series, status, subject, media, location and library items.
ACQUISTION FORM
This form is accessible only by a Librarian account. The form is used when a new item is acquired.
Acquisition details of the item is inputted, such as the items cost, acquisition date, supplier, PO number
and the name of the person who received the item.
CIRCULATION FORM
This form is accessible only by a Librarian account. The form is used to view the circulation records which
allow the Librarian to modify or create new circulation records without the need to use the Check-in and
Check-out Forms.
This form is accessible only by a Librarian account. The librarian can add, edit or remove Circulation
Types. The records specified here are used by the program when auto-calculating fines when returning
items late.
F. REPORTING SYSTEM
The reports menu is accessible only by the librarian and is used to view the different program reports.
DAILY FINES SUMMARY REPORT displays the summary of fines received for the last 30 days.
LIST OF BORROWED ITEMS REPORT displays the list of borrowed/unreturned library items.
TOP TEN MOST BORROWED ITEMS REPORT displays the top ten most borrowed library items.
LIST OF LIBRARY ITEMS BY LOCATION displays the list of library items grouped by location.
LIST OF PATRONS BY GROUP displays the list of patrons by group.
The patron menu is accessible only by the patrons and is used to view the Patron Record and Circulation
History.
THE PATRON RECORD FORM Used to display the currently logged on patrons record details.
THE CIRCULATION HISTORY FORM Used to display the currently logged on patrons circulation
history.