0% found this document useful (0 votes)
85 views24 pages

Application Using Flex Grid Control: Coding

The document describes an inventory management system using DAO (Data Access Objects) to connect to and manipulate data in an Access database. It includes coding for three forms - one each to manage item, purchase, and sales records. Each form initializes a DAO Recordset and Database object to work with the relevant database table. Buttons allow adding, deleting, navigating, and updating records in the Recordset directly from the form.

Uploaded by

Sekar Musiq
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
85 views24 pages

Application Using Flex Grid Control: Coding

The document describes an inventory management system using DAO (Data Access Objects) to connect to and manipulate data in an Access database. It includes coding for three forms - one each to manage item, purchase, and sales records. Each form initializes a DAO Recordset and Database object to work with the relevant database table. Buttons allow adding, deleting, navigating, and updating records in the Recordset directly from the form.

Uploaded by

Sekar Musiq
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 24

APPLICATION USING FLEX GRID CONTROL

Coding:

Dim a(0 To 10, 0 To 2) As Variant


Dim i As Integer

Private Sub add_Click()


MSFlexGrid1.AddItem Text1.Text & vbTab & Text2.Text & vbTab & Text3.Text &
vbTab & Text4.Text + vbCr
Text1 = ""
Text2 = ""
Text3 = ""
Text4 = ""
End Sub

Private Sub Form_Load()


Set Text1.Font = MSFlexGrid1.Font
Set Text2.Font = MSFlexGrid1.Font
Set Text3.Font = MSFlexGrid1.Font
Set Text4.Font = MSFlexGrid1.Font
MSFlexGrid1.Cols = 4
MSFlexGrid1.Rows = 2
MSFlexGrid1.Col = 0
MSFlexGrid1.Row = 0
MSFlexGrid1.Text = "Item no"
MSFlexGrid1.Col = 1
MSFlexGrid1.Text = "Item name"
MSFlexGrid1.Col = 2
MSFlexGrid1.Text = "Price"
MSFlexGrid1.Col = 3
MSFlexGrid1.Text = "Quantity"
MSFlexGrid1.Rows = 1
Show
End Sub

Private Sub Text1_KeyPress(KeyAscii As Integer)


If Not (KeyAscii >= Asc("0") And KeyAscii <= Asc("9")) Then
MsgBox "Invalid number", vbOKOnly + vbQuestion
KeyAscii = 0
End If
End Sub

Private Sub Text2_KeyPress(KeyAscii As Integer)


Select Case KeyAscii
Case Asc("a") To Asc("z")
Case Asc("A") To Asc("Z")
Case Else
MsgBox "Invalid character", vbOKOnly + vbQuestion
KeyAscii = 0
End Select
End Sub

Private Sub Text3_KeyPress(KeyAscii As Integer)


If Not (KeyAscii >= Asc("0") And KeyAscii <= Asc("9")) Then
MsgBox "Invalid number", vbOKOnly + vbQuestion
KeyAscii = 0
End If
End Sub

Private Sub Text4_KeyPress(KeyAscii As Integer)


If Not (KeyAscii >= Asc("0") And KeyAscii <= Asc("9")) Then
MsgBox "Invalid number", vbOKOnly + vbQuestion
KeyAscii = 0
End If
End Sub

Private Sub viewstatus_Click()


For i = 0 To MSFlexGrid1.Rows - 1
MSFlexGrid1.Col = 0
MSFlexGrid1.Row = i
a(i, 0) = MSFlexGrid1.Text
MSFlexGrid1.Col = 3
a(i, 1) = MSFlexGrid1.Text
Next i
MSChart1.ChartData = a
End Sub
Form design
Output:
EMPLOYEE PAY SLIP USING DATA CONTROL

Coding:

Private Sub add_Click()


Data1.Recordset.AddNew
End Sub
Private Sub delete_Click()
Data1.Recordset.delete
End Sub
Private Sub find_Click()
n = InputBox("enter the regno to find")
Data1.Recordset.movefirst
Data1.Recordset.find ("regno= ' " & n & " ' ")
End Sub
Private Sub movefirst_Click()
Data1.Recordset.movefirst
End Sub
Private Sub movelast_Click()
Data1.Recordset.movelast
End Sub
Private Sub movenext_Click()
Data1.Recordset.movenext
If Data1.Recordset.EOF Then
Data1.Recordset.movelast
End If
End Sub
Private Sub moveprevious_Click()
Data1.Recordset.moveprevious
If Data1.Recordset.BOF Then
Data1.Recordset.movefirst
End If
End Sub
Private Sub update_Click()
hra = ((Text5.Text) * 5) / 100
Text6.Text = hra
da = ((Text5.Text) * 3) / 100
Text7.Text = da
pf = ((Text5.Text) * 2) / 100
Text8.Text = pf
gp = Text5.Text + hra + da
Text9.Text = gp
np = gp - pf
Text10.Text = np
Data1.Recordset.update
MSFlexGrid1.Refresh
End Sub
Form design:
Output:
LIBRARY MAINTAINANCE SYSTEM USING ADODB

Coding:

Dim c As New ADODB.Connection


Dim rs As New ADODB.Recordset

Private Sub Adodc1_WillMove(ByVal adReason As ADODB.EventReasonEnum,


adStatus As ADODB.EventStatusEnum, ByVal pRecordset As ADODB.Recordset)
End Sub

Private Sub Command1_Click()


rs.MoveFirst
Text1 = rs(0)
Text2 = rs(1)
Text3 = rs(2)
Text4 = rs(3)
Text5 = rs(4)
Text6 = rs(5)
Text7 = rs(6)
End Sub

Private Sub Command2_Click()


rs.MovePrevious
If rs.BOF Then
rs.MovePrevious
End If
Text1 = rs(0)
Text2 = rs(1)
Text3 = rs(2)
Text4 = rs(3)
Text5 = rs(4)
Text6 = rs(5)
Text7 = rs(6)
End Sub

Private Sub Command3_Click()


rs.MoveNext
If rs.EOF Then
rs.MoveNext
End If
Text1 = rs(0)
Text2 = rs(1)
Text3 = rs(2)
Text4 = rs(3)
Text5 = rs(4)
Text6 = rs(5)
Text7 = rs(6)
End Sub

Private Sub Command4_Click()


rs.MoveLast
Text1 = rs(0)
Text2 = rs(1)
Text3 = rs(2)
Text4 = rs(3)
Text5 = rs(4)
Text6 = rs(5)
Text7 = rs(6)
End Sub

Private Sub Command5_Click()


rs.AddNew
End Sub

Private Sub Command6_Click()


rs.Update
End Sub

Private Sub Command7_Click()


rs.Delete
End Sub

Private Sub Form_Load()


c.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=E:\yogavb\stduent.mdb;Persist Security Info=False"
c.Open
rs.Open "select * from bookd", c, 3, 3
Text1 = rs(0)
Text2 = rs(1)
Text3 = rs(2)
Text4 = rs(3)
Text5 = rs(4)
Text6 = rs(5)
Text7 = rs(6)
End Sub
Form design:

Form1:

Form2:
Form3:

MDI Form:
STUDENT INFORMATION SYSTEM USING ADO CONTROL

Coding:

Private Sub add_Click()


Adodc1.Recordset.AddNew
End Sub

Private Sub delete_Click()


Adodc1.Recordset.delete
Adodc1.Recordset.movenext
End Sub

Private Sub find_Click()


n = InputBox("enter the regno to find")
Adodc1.Recordset.movefirst
Adodc1.Recordset.find ("regno='" & n & " ' ")
End Sub

Private Sub movefirst_Click()


Adodc1.Recordset.movefirst
End Sub

Private Sub movelast_Click()


Adodc1.Recordset.movelast
End Sub

Private Sub movenext_Click()


Adodc1.Recordset.movenext
If Adodc1.Recordset.EOF Then
Adodc1.Recordset.movelast
End If
End Sub

Private Sub moveprevious_Click()


Adodc1.Recordset.moveprevious
If Adodc1.Recordset.BOF Then
Adodc1.Recordset.movefirst
End If
End Sub

Private Sub report_Click()


DataReport1.Show
End Sub
Private Sub update_Click()
Adodc1.Recordset.update
MsgBox "update successfully", vbOKOnly
End Sub
Form design:
OUTPUT:
FONT DIALOG BOX

Coding:

Private Sub Combo1_Click()


Label5.FontName = Combo1.Text
End Sub

Private Sub Combo2_Click()


Label5.FontSize = Combo2.Text
End Sub

Private Sub list1_click()


If List1.Text = "Bold" Then
Label5.FontBold = Not (FontBold)
ElseIf List1.Text = "Italic" Then
Label5.FontItalic = Not (FontItalic)
ElseIf List1.Text = "Underline" Then
Label5.FontUnderline = Not (FontUnderline)
ElseIf List1.Text = "Strike Thru" Then
Label5.FontStrikethru = Not (FontStrikethru)
End If
End Sub

Private Sub Form_Load()


WindowState = 2
For i = 0 To Screen.FontCount - 1
Font.Name = Screen.Fonts(i)
Combo1.AddItem Screen.Fonts(i)
Next i
For j = 8 To 100
Combo2.AddItem j
j=j+2
Next j
List1.AddItem "bold"
List1.AddItem "Italic"
List1.AddItem "Underline"
List1.AddItem "Strike Thru"
End Sub

Private Sub Label7_Click()


CommonDialog1.ShowColor
Label5.ForeColor = CommonDialog1.Color
End Sub
Form Design:
Output:
INVENTORY SYSTEM USING DAO

Coding:

Form 1

Dim db As DAO.Database
Dim rs As DAO.Recordset

Private Sub add_Click()


Text1 = ""
Text2 = ""
Text3 = ""
Text4 = ""
Text5 = ""
rs.AddNew
End Sub

Private Sub delete_Click()


rs.delete
End Sub

Private Sub Form_Load()


Set db = OpenDatabase("E:\inven.mdb")
Set rs = db.OpenRecordset("Select * from item ")
If rs.RecordCount > 0 Then
rs.MoveFirst
Text1 = rs(0)
Text2 = rs(1)
Text3 = rs(2)
Text4 = rs(3)
Text5 = rs(4)
End If
End Sub

Private Sub mof_Click()


rs.MoveFirst
Text1 = rs(0)
Text2 = rs(1)
Text3 = rs(2)
Text4 = rs(3)
Text5 = rs(4)
End Sub

Private Sub mol_Click()


rs.MoveLast
Text1 = rs(0)
Text2 = rs(1)
Text3 = rs(2)
Text4 = rs(3)
Text5 = rs(4)
End Sub

Private Sub mon_Click()


rs.MoveNext
If rs.EOF Then
rs.MoveFirst
End If
Text1 = rs(0)
Text2 = rs(1)
Text3 = rs(2)
Text4 = rs(3)
Text5 = rs(4)
End Sub

Private Sub mop_Click()


rs.MovePrevious
If rs.BOF Then
rs.MoveNext
End If
Text1 = rs(0)
Text2 = rs(1)
Text3 = rs(2)
Text4 = rs(3)
Text5 = rs(4)
End Sub

Private Sub up_Click()


rs.Update
MsgBox "updated successfully"
End Sub

Form2:

Dim db1 As DAO.Database


Dim rs1 As DAO.Recordset

Private Sub add_Click()


Text1 = ""
Text2 = ""
Text3 = ""
Text4 = ""
Text5 = ""
rs1.AddNew
End Sub

Private Sub delete_Click()


rs1.delete
End Sub

Private Sub Form_Load()


Set db1 = OpenDatabase("E:\inven.mdb")
Set rs1 = db1.OpenRecordset("Select * from purchase ")
If rs1.RecordCount > 0 Then
rs1.MoveFirst
Text1 = rs1(0)
Text2 = rs1(1)
Text3 = rs1(2)
Text4 = rs1(3)
Text5 = rs1(4)
End If
End Sub

Private Sub mof_Click()


rs1.MoveFirst
Text1 = rs1(0)
Text2 = rs1(1)
Text3 = rs1(2)
Text4 = rs1(3)
Text5 = rs1(4)
End Sub

Private Sub mol_Click()


rs1.MoveLast
Text1 = rs1(0)
Text2 = rs1(1)
Text3 = rs1(2)
Text4 = rs1(3)
Text5 = rs1(4)
End Sub

Private Sub mon_Click()


rs1.MoveNext
If rs1.EOF Then
rs1.MoveFirst
End If
Text1 = rs1(0)
Text2 = rs1(1)
Text3 = rs1(2)
Text4 = rs1(3)
Text5 = rs1(4)
End Sub

Private Sub mop_Click()


rs1.MovePrevious
If rs1.BOF Then
rs1.MoveNext
End If
Text1 = rs1(0)
Text2 = rs1(1)
Text3 = rs1(2)
Text4 = rs1(3)
Text5 = rs1(4)
End Sub

Private Sub up_Click()


rs1.Update
MsgBox "updated successfully"
End Sub

Form3:

Dim db2 As DAO.Database


Dim rs2 As DAO.Recordset

Private Sub add_Click()


Text1 = ""
Text2 = ""
Text3 = ""
Text4 = ""
Text5 = ""
Text6 = ""
rs2.AddNew
End Sub

Private Sub delete_Click()


rs2.delete
End Sub

Private Sub Form_Load()


Set db2 = OpenDatabase("E:\inven.mdb")
Set rs2 = db2.OpenRecordset("Select * from sales ")
If rs2.RecordCount > 0 Then
rs2.MoveFirst
Text1 = rs2(0)
Text2 = rs2(1)
Text3 = rs2(2)
Text4 = rs2(3)
Text5 = rs2(4)
Text6 = rs2(5)
End If
End Sub

Private Sub mof_Click()


rs.MoveFirst
Text1 = rs2(0)
Text2 = rs2(1)
Text3 = rs2(2)
Text4 = rs2(3)
Text5 = rs2(4)
Text6 = rs2(5)
End Sub

Private Sub mol_Click()


rs.MoveLast
Text1 = rs2(0)
Text2 = rs2(1)
Text3 = rs2(2)
Text4 = rs2(3)
Text5 = rs2(4)
Text6 = rs2(5)
End Sub

Private Sub mon_Click()


rs2.MoveNext
If rs2.EOF Then
rs2.MoveFirst
End If
Text1 = rs2(0)
Text2 = rs2(1)
Text3 = rs2(2)
Text4 = rs2(3)
Text5 = rs2(4)
Text6 = rs2(5)
End Sub

Private Sub mop_Click()


rs2.MovePrevious
If rs2.BOF Then
rs2.MoveNext
End If
Text1 = rs2(0)
Text2 = rs2(1)
Text3 = rs2(2)
Text4 = rs2(3)
Text5 = rs2(4)
Text6 = rs2(5)
End Sub

Private Sub up_Click()


rs2.Update
MsgBox "updated successfully"
End Sub
Form Design:

Form1:

Form2:

Form3:
Output:

Form1:

Form2:

Form3:

You might also like