Program to save customer details and print details of bill using DAO
Sample :
I can't show you complete code Directly so download full code from below .
Dim db As Database
Dim rs As Recordset
Private Function loadid()
Dim tem As Recordset
Set tem = db.OpenRecordset("record")
Combo.Clear
While tem.EOF = False
Combo.AddItem (tem.Fields(0))
tem.MoveNext
Wend
End Function
Private Sub cmddelcustomer_Click()
rs.Delete
Dim i As Single
For i = 0 To 6
Text(i).Text = ""
Next i
Combo.Clear
loadid
Frame1.Enabled = False
Frame2.Enabled = False
cmddelcustomer.Enabled = False
End Sub
Private Sub cmdnewbill_Click()
If (Text(3).Text <> "") And (Text(4).Text <> "") Then
Text(3).Text = Text(4).Text
Text(4).Text = ""
Text(5).Text = ""
Text(6).Text = ""
Text(4).SetFocus
Text(4).Locked = False
rs.Edit
cmdsave.Enabled = True
End If
End Sub
Private Sub cmdnewcustomer_Click()
Combo.Text = ""
Combo.Enabled = False
Dim i As Single
For i = 0 To 6
Text(i).Text = ""
Next i
general False
bill False
rs.AddNew
cmdedit.Enabled = False
cmdnewbill.Enabled = False
cmdsave.Enabled = True
Frame1.Enabled = True
Frame2.Enabled = True
End Sub
Private Sub cmdsave_Click()
If Text(6) <> "" Then
Dim i As Integer
For i = 0 To 6
rs.Fields(i) = Text(i).Text
Next i
rs.Update
MsgBox ("Save sucessfully")
loadid
cmdsave.Enabled = False
cmdedit.Enabled = True
cmdnewbill.Enabled = True
Combo.Enabled = True
Else
MsgBox ("Please Fill all ")
End If
End Sub
Private Sub Combo_Click()
rs.MoveFirst
While (rs.EOF = False) And (rs.Fields(0) <> Combo.Text)
rs.MoveNext
Wend
Dim i As Single
For i = 0 To 6
Text(i) = rs.Fields(i)
Next i
cmdsave2.Enabled = False
Frame1.Enabled = True
Frame2.Enabled = True
cmddelcustomer.Enabled = True
End Sub
Private Function general(b As Boolean)
Dim i As Single
For i = 0 To 2
Text(i).Locked = b
Next i
End Function
Private Function bill(b As Boolean)
Dim i As Single
For i = 3 To 6
Text(i).Locked = b
Next i
End Function
Private Sub Form_Load()
Set db = OpenDatabase("Database.mdb")
Set rs = db.OpenRecordset("record")
loadid
general True
bill True
Frame1.Enabled = False
Frame2.Enabled = False
cmddelcustomer.Enabled = False
End Sub
Private Sub Text_Change(Index As Integer)
If Text(4) <> "" Then
Text(5).Text = Val(Text(4).Text) - Val(Text(3).Text)
Dim ans, unit As Double
unit = Val(Text(5).Text)
Select Case unit
Case Is <= 200
ans = 1 * unit
Case Is <= 400
ans = 200 + 5 * unit
Case Is <= 600
ans = 1200 + 10 * unit
Case Is > 600
ans = 3200 + 20 * unit
End Select
Text(6).Text = ans
End If
End Sub
0 comments:
Post a Comment