Dim con As New ADODB.Connection
Dim rs As New ADODB.Recordset
Private Sub cmdClear_Click()
'Call clear1
'cmdSave.Enabled = True
'Text1.SetFocus
Text1.Text = " "
Text2.Text = " "
Option1. Value = False
0ption2.Value = False
Text1.SetFocus
End Sub
Private Sub cmdDelete_Click()
a = MsgBox("Are you sure?", vbYesNo, "CONFORMATION ALERT")
If a = vbYes Then
con.Execute "delete from employee where empcode=" &
Text1.Text
MsgBox " Record deleted ...."
If rs.State = adStateOpen Then
rs.Close
End If
rs.Open "select * from employee", con, adOpenDynamic,
adLockBatchOptimistic
rs.MoveFirst
Call show1
End If
End Sub
Private Sub cmdFisrt_Click()
If rs.State = adStateOpen Then
rs.Close
End If
rs.0pen "select * from employee",con, adOpenDynamic,
adLockBatchOptimistic
rs.MoveFirst
Call show1
End Sub
Private Sub cmdLast_Click()
If rs.State = adStateOpen Then
rs.Close
End If
rs.Open "select *from employee",con, adOpenDynamic
rs.MoveLast
Call show1
End Sub
Private Sub cmdModify_Click()
If Option1.Value = True Then
marstatus = "Single"
End If
If Option2.Value = True Then
marstatus = "Double"
End If
con.Execute "update employee set empname=" & Text2.Text &
" ', marstatus=' " & marstatus & " ' where empcode=" & " ' where empcode=" &
Text1.Text
MsgBox "Record Modified.....",vbOKOnly, "Update"
End Sub
Private Sub cmdNext_Click()
If rs.State = adStateOpen Then
rs.Close
End If
rs.Open "select * from employee", con,adOpenDynamic,
adLockBatchOptimistic
rs.MoveNext
If rs.EOF = True Then
rs.MoveLast
MsgBox "End of File encountered",vbOKOnly,"eof "
End If
Call show1
End Sub
Private Sub cmdPrevious_Click()
If rs. State = adStateOpen Then
rs.Close
End If
rs.Open "select * from employee",con, adOpenDynamic,
adLockBatchOptimistic
rs.MovePrevious
If rs.BOF = True Then
rs.MoveFirst
MsgBox "Begining Of File encounter..", vbOKOnly, "BOF"
End If
Call show1
End Sub
Private Sub cmdSave_Click()
If Option1. Value = True Then
marstatus = "Single"
End If
If Option2. Value = True Then
marstatus = "Double"
End If
con.Execute "insert into employee values(" & Text1.Text & ", ' " & Text2. Text &" ', ' " & marstatus & " ')"
MsgBox " Record saved....",vbOKOnly, "Save"
rs. Close
rs.Open
'cmdSave. Enabled = False
End Sub
Private Sub Command9_Click()
Unload Me
End Sub
Private Sub Form_Load()
con.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=D:\adodb\connection.mdb;Persist Security Info=False"
If rs.State= adStateOpen Then
rs.Close
End If
rs.Open "select * from employee", con, adOpenDynamic,
adLockBatchOptimistic
If (rs.EOF= False And rs.BOF = False) Then
Call show1
'cmdSave. Enabled = False
End If
End Sub
Private Sub Form_Resize()
Frame1.Left = (Me.Width - Frame1.Width) / 2 - 50
Frame1.Top = (Me. Height - Frame1.Height) / 2 - 230
End Sub
Private Sub show1()
Text1.Text = rs! empcode
Text2.Text = rs! empname
If Trim (rs! marstatus) = "Single" Then
Option1.Value = True
Else
'If rs!marstatus = "Single" Then
Option2. Value = True
End If
End Sub
No comments:
Post a Comment