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, Tweet it or share this article on other bookmarking websites.

Comments (0)

There are no comments posted here yet

Which festival you have enjoyed most in October, 2011?

October 2011 is a month of  festivals. Many festival has taken place in this month. Kindly choose one option, the festival you have enjoyed most.

No answer selected. Please try again.
Please select either existing option or enter your own, however not both.
Please select minimum 0 answer(s) and maximum 5 answer(s).
/polls/funny-polls/6150-which-festival-you-have-enjoyed-most-in-october-2011.json?task=poll.vote
6150
radio
[{"id":"21172","title":"Durga Puja \/ Dashera","votes":"27","type":"x","order":"0","pct":29.35,"resources":[]},{"id":"21173","title":"Lakshmi Puja","votes":"10","type":"x","order":"0","pct":10.87,"resources":[]},{"id":"21174","title":"Kali Puja","votes":"4","type":"x","order":"0","pct":4.35,"resources":[]},{"id":"21175","title":"Diwali","votes":"50","type":"x","order":"0","pct":54.35,"resources":[]},{"id":"21176","title":"Bhaidooj","votes":"1","type":"x","order":"0","pct":1.09,"resources":[]}] ["#ff5b00","#4ac0f2","#b80028","#eef66c","#60bb22","#b96a9a","#62c2cc"] ["rgba(255,91,0,0.7)","rgba(74,192,242,0.7)","rgba(184,0,40,0.7)","rgba(238,246,108,0.7)","rgba(96,187,34,0.7)","rgba(185,106,154,0.7)","rgba(98,194,204,0.7)"] 350
bottom 200
No married couple wants to end up getting divorced. It is not like they have planned for it. They try to put up with their partners for as long as they
Due to our modern lifestyle, we feel that digestion related disorders are a common problem. Thus, we neither give importance to them nor seek any help
The bond of marriage brings the two people together. Initially, everything may seem okay and both of them slowly start discovering each other in the journey.
The beginning I have been long wanting to write this tale but now that 20 years away elapsed I think I can put this lovely story on paper. Close
The state of Jammu and Kashmir is supposed to be an integral part of the country. Despite this, the state has its own constitution and flag. It is also
Imperialism is derived from the Latin word 'imperium' which means 'right to rule'.The definition of imperialism is the domination of undeveloped nation
A revolution that took place in Russia during an international war i.e. World War I is called as Russian Revolution. World War I started in 1914 and ended
The 18th century is known as the 'Age of Revolutions', as the three important revolutions took place in this century. 1. American War of Independence.