Customer

Dim flag As Boolean
Dim strn As String
Dim strn1 As String
Dim re As Integer
Dim ss1 As Boolean
 Private Sub Command1_Click()
Form1.Visible = False
Load Form2
Form2.Visible = True
End Sub
 Private Sub Command2_Click()
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
Text4.Text = ""
Text5.Text = ""
Text6.Text = ""
End Sub
 Private Sub Command3_Click()
If Text1.Text = "" Or Text2.Text = "" Or Text3.Text = "" Or Text4.Text = "" Or Text5.Text = "" Or Text6.Text = "" Then
MsgBox "Enter Data"
Text1.SetFocus
Else
 flag = True
strn = UCase(Text1.Text)
 
If rs.State = 1 Then rs.Close
rs.Open "select distinct name  from  Cust_Data", con, adOpenDynamic, adLockOptimistic
While Not rs.EOF
re = 0
strn1 = UCase(rs.Fields(0).value)
 re = StrComp(strn, strn1)
 If re = 0 Then
ss1 = True
Command2_Click
flag = False
 End If
rs.MoveNext
Wend
If ss1 = True Then
MsgBox "Name Duplication"
ss1 = False
End If
If rs.State = 1 Then rs.Close
If flag = True Then
Module1.name = strn
'rs.Open "insert into Cust_Data values('" & Text1.Text & "','" & Text2.Text & "','" & Text3.Text & "','" & Text4.Text & "','" & Text5.Text & "')", con, adOpenDynamic, adLockOptimistic
rs1.AddNew
rs1.Fields(0).value = strn
rs1.Fields(1).value = Text2.Text
rs1.Fields(2).value = Text3.Text
rs1.Fields(3).value = Text4.Text
rs1.Fields(4).value = Text5.Text
rs1.Fields(5).value = Text6.Text
rs1.Update
End If
End If
End Sub
 Public Sub display()
Text1.Text = rs1.Fields(0).value
Text2.Text = rs1.Fields(1).value
Text3.Text = rs1.Fields(2).value
Text4.Text = rs1.Fields(3).value
Text5.Text = rs1.Fields(4).value
Text6.Text = rs1.Fields(5).value
 End Sub
 Private Sub Command4_Click()
'Command5.Enabled = True
'Command6.Enabled = False
 rs1.MoveFirst
display
End Sub
 
Private Sub Command5_Click()
rs1.MoveNext
If rs1.EOF Then
rs1.MoveLast
'Command5.Enabled = False
'Command6.Enabled = True
End If
display
End Sub
 Private Sub Command6_Click()
rs1.MovePrevious
If rs1.BOF Then
rs1.MoveFirst
' Command6.Enabled = False
' Command5.Enabled = True
End If
display
End Sub
 Private Sub Command7_Click()
'Command6.Enabled = True
'Command5.Enabled = False
 rs1.MoveLast
display
End Sub
 Private Sub Command8_Click()
Dim ans
ans = MsgBox("DO You Want To Update Record", vbYesNo + vbQuestion, "UPDATE")
If ans = vbYes Then
rs1.Fields(0).value = Text1.Text
rs1.Fields(1).value = Text2.Text
rs1.Fields(2).value = Text3.Text
rs1.Fields(3).value = Text4.Text
rs1.Fields(4).value = Text5.Text
rs1.Fields(5).value = Text6.Text
  rs1.Update
MsgBox "Record updated"
Else
MsgBox "Record is as it is"
End If
End Sub
 Private Sub Command9_Click()
 
If rs1.EOF Then
rs1.MovePrevious
rs1.Delete
 rs1.MovePrevious
 Else
 rs1.Delete
rs1.MoveNext
 End If
If rs.State = 1 Then rs.Close
Dim ans
ans = MsgBox("Do you want to delete this record ? ", vbYesNo + vbQuestion, "Confirm")
If ans = vbYes Then
rs.Open "delete from Customer where Cust_ID='" & Text1.Text & "'", con, adOpenDynamic, adLockOptimistic
End If
 If rs.State = 1 Then rs.Close
 End Sub
 Private Sub Form_Activate()
If rs1.State = 1 Then rs1.Close
rs1.Open "select * from Cust_Data", con, adOpenDynamic, adLockOptimistic
StatusBar1.Panels(2).Text = Now()
 End Sub
 
 
 Private Sub Form_Deactivate()
If rs1.State = 1 Then rs1.Close
End Sub
 Private Sub Form_Load()
Form1.Top = MDIForm1.Top + (MDIForm1.Height - Form1.Height) / 2
Form1.Left = MDIForm1.Left + (MDIForm1.Width - Form1.Width) / 2
 End Sub
 Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
If rs1.State = 1 Then rs1.Close
End Sub
 Private Sub Text5_KeyPress(KeyAscii As Integer)
If KeyAscii >= 48 And KeyAscii <= 57 Or KeyAscii = 8 Then
StatusBar1.Panels(1).Text = ""
Else
KeyAscii = 0
StatusBar1.Panels(1).Text = "Please Enter Numeric value"
 End If
End Sub
Private Sub Text6_KeyPress(KeyAscii As Integer)
If KeyAscii >= 48 And KeyAscii <= 57 Or KeyAscii = 8 Then
StatusBar1.Panels(1).Text = ""
Else
KeyAscii = 0
StatusBar1.Panels(1).Text = "Please Enter Numeric value"
End If
End Sub

 

 


Like it on Facebook, +1 on Google, Tweet it or share this article on other bookmarking websites.

Comments (0)

There are no comments posted here yet