Library Management
Library Management
Book Table
The book table in Access Design View is given below. One of the Field
Name is “Primary Key”, in this case, BookID.
Relationship
A relationship is MS Access is similar to the e-r diagram we created
previously. We can use the e-r diagram to create relationships between
tables.
Relationships Between
Tables – Library Management System
The relationship between Member and Borrow is called One-to-
Many and the relationship between Book and Borrow is One-to-Many.
Relationship Types
Connect to MS Access Database Using 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 10, then these extra line of codes
become redundant. To save us from this trouble, create Module1.bas file
from Project1.vbp windows.The code for Module is given below.
Name:frmLibraryManagement
Caption :LIBRARY MANAGEMENT SYSTEM
BackColor :Window Text
ForeColor : Highlight Text
Now add a frame control and add all other controls on top of it.
Frame
Name:frameLibraryManagement
Caption :Library Management
BackColor :Window Text
ForeColor : Highlight Text
Labels
Name : lblLibraryManagement
Caption : LIBRARY MANAGEMENT SYSTEM
BackColor :Window Text
ForeColor : Highlight Text
Font :Arimo 18px Bold
Name : lblCompany
Caption : NotesforMSc
BackColor :Window Text
ForeColor : Highlight Text
Font : MS Sans-serif 12px Bold
Name : lblCopyright
Caption : Copyright : https://notesformsc.org
BackColor :Window Text
ForeColor : Highlight Text
Font : MS Sans-serif px Bold
Buttons
Name : cmdLogin
Caption : Login
BackColor : Button Highlight
Font : MS Sans-serif 12px Bold
Style :1-Graphical
Code for frmLibraryManagement
Private Sub cmdLogin_Click()
frmLogin.Show
Unload Me
End Sub
Components for frmLogin
The login screen is different because you want password to be hidden
when you type them. To create Login dialog, {Right-
Click] Project.vbp > Select Add > [Click] Form. The new form dialog
box will appear, select Log in Dialog.
Login Dialog –
Library Management System
Now we must rename and change the code for frmLogin.
Name : lblUserID
Caption : UserID
BackColor : Window Text
ForeColor : Highlight Text
Name : lblPassword
Caption : Password
BackColor : Window text
ForeColor : Highlight Text
Text-Boxes
Name: txtUserID
Text : 'leave blank'
Name : txtPassword
Text : 'leave blank'
Buttons
Name : cmdOk
Caption : OK
Name: cmdCancel
Caption : Cancel
Code for frmLogin
Option Explicit
Else
End If
End If
rs.MoveNext
Wend
End Sub
Name : frmBook
Caption : Book Details
BackColor : Window Text
ForeColor : Highlight Text
First create a single frame control and add all other controls on top of it.
Name : frameBook
Caption : Book Details
BackColor : Window Text
ForeColor : Highlight Text
Labels
Name : lblBookMain
Alignment : Center
Caption : Book Details
BackColor : Window Text
ForeColor : Highlight Text
Font : Arimo 18px Bold
Name : lblBookID
Alignment : Center
Caption : BOOK ID
BackColor : Window Text
ForeColor : Highlight Text
Font : MS Sans-serif 8px Bold
Name : lblBookTitle
Alignment : Center
Caption : BOOK TITLE
BackColor : Window Text
ForeColor : Highlight Text
Font : MS Sans-serif 8px Bold
Name : lblAuthor
Alignment : Center
Caption : AUTHOR
BackColor : Window Text
ForeColor : Highlight Text
Font : MS Sans-serif 8px Bold
Name : lblBNote
Alignment : Center
Caption : NOTE:
BackColor : Window Text
ForeColor : Highlight Text
Font : MS Sans-serif 8px Bold
Name : lblBInstruction
Alignment : Center
Caption : Only use BOOK ID for DISPLAY
BackColor : Window Text
ForeColor : Highlight Text
Font : MS Sans-serif 8px Bold
Textboxes
Name : txtBookID
Text :'leave empty'
Name : txtBookTitle
Text :'leave empty'
Name :txtAuthor
Text: 'leave empty'
Buttons
Name : cmdBAdd
Caption : &ADD
BackColor : Button Highlight
Style : 1-Graphical
Name : cmdBDelete
Caption : &DELETE
BackColor : Button Highlight
Style : 1-Graphical
Name : cmdBUpdate
Caption : &UPDATE
BackColor : Button Highlight
Style : 1-Graphical
Name : cmdBDisplay
Caption : &DISPLAY
BackColor : Button Highlight
Style : 1-Graphical
Name : cmdClear
Caption : &CLEAR
BackColor : Button Highlight
Style : 1-Graphical
Name : cmdBExit
Caption : &EXIT
BackColor : Button Highlight
Style : 1-Graphical
Name : cmdBCatalog
Caption : &CATALOG
BackColor : Button Highlight
Style : 1-Graphical
DataGrid Control
Name : BookFinder
Code for frmBook
Option Explicit
Call loadcon
rs.CursorLocation = adUseClient
rs.Open "SELECT Book.[BookID], Book.[BookTitle],Borrow.
[MemberID],Member.[MemberName],Borrow.[StartDate] FROM
Book,Borrow,Member WHERE Book.[BookID] = " & txtBookID & " And Book.
[BookID]= Borrow.[BookID]And Borrow.[MemberID]=Member.[MemberID]
And Borrow.[Return] = 0", con, adOpenDynamic, adLockOptimistic
If Dir$("C:/VBProjects/Library/savebookdisplay.xml" ) <> "" Then
Kill "C:/VBProjects/Library/savebookdisplay.xml"
End If
rs.Save "C:/VBProjects/Library/savebookdisplay.xml" , adPersistXML
rs.Close
con.Close
Set rs = Nothing
rs.Open "C:/VBProjects/Library/savebookdisplay.xml" , , adOpenKeyset,
adLockBatchOptimistic, adCmdFile
Set BookFinder.DataSource = rs
Set rs = Nothing
End Sub
Private Sub cmdBExit_Click()
Unload Me
End Sub
Name : frmMember
Caption : Member
BackColor : Window Text
ForeColor : Highlight Text
Frame Control
Name : frameMember
Caption : Member Registration
BackColor : Window Text
ForeColor : Highlight Text
Now you can start adding all the other control on top of frame. You want
to make controls visible on frame,then right click frame and click send
to back.
Labels
Name :lblMemberMain
Alignment :Center
Caption : Member Information
BackColor : Window Text
ForeColor : Highlight Text
Font : Arimo 18px Bold
Name :lblMID
Caption : Member ID
BackColor : Window Text
ForeColor : Highlight Text
Font :MS Sans-serif 8px Bold
Name :lblMName
Caption : Member Name
BackColor : Window Text
ForeColor : Highlight Text
Font :MS Sans-serif 8px Bold
Name :lblMNote
Caption : NOTE:
BackColor : Window Text
ForeColor : Highlight Text
Font :MS Sans-serif 8px Bold
Name :lblMInstruction
Caption : Only use Member ID before DISPLAY
BackColor : Window Text
ForeColor : Highlight Text
Font :MS Sans-serif 8px Bold
Textboxes
Name: txtMID
Text :'leave blank'
Name: txtMName
Text :'leave blank'
Name: txtMPass
Text :'leave blank'
Buttons
Name :cmdMAdd
Caption : &ADD
BackColor : Window Text
Style : 1-Graphical
Name :cmdMDel
Caption : &DELETE
BackColor : Window Text
Style : 1-Graphical
Name :cmdMUpdate
Caption : &UPDATE
BackColor : Window Text
Style : 1-Graphical
Name :cmdMDisplay
Caption : &DISPLAY
BackColor : Window Text
Style : 1-Graphical
Name :cmdMClear
Caption : &CLEAR
BackColor : Window Text
Style : 1-Graphical
Name :cmdMExit
Caption : &EXIT
BackColor : Window Text
Style : 1-Graphical
Name :cmdMAllMember
Caption : &Show Members
BackColor : Window Text
Style : 1-Graphical
DataGrid Control
Name :MemberFinder
Code for frmMember
Name : frameBookBorrow
Caption : Book Borrow
BackColor : Window Text
ForeColor : Highlight Text
Name : frameAvailibility
Caption : Availibility
BackColor : Window Text
ForeColor : Highlight Text
Once you have created a frame control, add other controls on top of it.
Also right click frame and send to back the frame.
Under the frame book borrow add following controls.
Labels
Name : lblBorrowMain
Caption : Book Borrow Details
BackColor : Window Text
ForeColor :Highlight Text
Font : Arimo 18px Bold
Name : lblBBookID
Caption : Book ID
BackColor : Window Text
ForeColor :Highlight Text
Font : MS Sans-serif 8px Bold
Name : lblBTitle
Caption : Book Title
BackColor : Window Text
ForeColor :Highlight Text
Font : MS Sans-serif 8px Bold
Name : lblBMemberID
Caption : Member ID
BackColor : Window Text
ForeColor :Highlight Text
Font : MS Sans-serif 8px Bold
Name : lblBorrowNote
Caption : NOTE:
BackColor : Window Text
ForeColor :Highlight Text
Font : MS Sans-serif 8px Bold
Name : lblBInstructions
Caption : Always CLEAR before any Query or Update
BackColor : Window Text
ForeColor :Highlight Text
Font : MS Sans-serif 8px Bold
Textboxes
Name : txtBBookID
Text : 'leave blank'
Name : txtBTitle
Text : 'leave blank'
Name : txtBMemberID
Text : 'leave blank'
Buttons
Name : cmdBorrow
Caption :&Borrow
BackColor : Window Text
ForeColor : Highlight Text
Style :1-Graphical
Name : cmdReturn
Caption :&Return
BackColor : Window Text
ForeColor : Highlight Text
Style :1-Graphical
Name : cmdBClear
Caption :&Clear
BackColor : Window Text
ForeColor : Highlight Text
Style :1-Graphical
Name : cmdExit
Caption :&Exit
BackColor : Window Text
ForeColor : Highlight Text
Style :1-Graphical
Now you can add controls under Check Availability frame.
Name : lblBBookTitle
Caption : Book Title
BackColor : Window Text
ForeColor : Highlight Text
Font : MS Sans-serif 8px Bold
Name : lblBResult
Caption : Result
BackColor : Window Text
ForeColor : Highlight Text
Font : MS Sans-serif 8px Bold
Textboxes
Name :txtBBookTitle
Text : 'leave blank'
Name :txtBResult
Text : 'leave blank'
Buttons
Name : cmdAvailibility
Caption :&Check Availibility
BackColor : Window Text
ForeColor : Highlight Text
Style :1-Graphical
Code for frmBorrow
End Sub
Borrow Book
Name : borrow
Caption : Borrow Book
Index: 3
Member Details
Name : members
Caption : Member Details
Index : 1
Book Details
Name : books
Caption : Book Details
Index : 2
Exit
Name : exit
Caption : Exit
Index : 0
Code for frmMenu
Before adding code for frmMENU, make sure you have created all other
forms of the Library Management Project,
When you click on any menu item it will open another form within the
parent MDI form. The other form that must open within MDI form
should have their MDI child property set to True.