coding
TRANSCRIPT
vOption ExplicitDim oper As StringDim mchoice As IntegerDim mrollno As Integer
Private Sub CMDADD_Click()oper = "ADD"cleardisabletxtRollno.SetFocusEnd Sub
Private Sub CMDCANCEL_Click()oper = ""Displayable
End Sub
Private Sub CMDDELETE_Click()mchoice = MsgBox("Are you Sure", vbYesNo + vbQuestion)If mchoice = vbYes Thenstu.Recordset.Deletestu.Recordset.MoveNextIf stu.Recordset.RecordCount = 0 ThenMsgBox "No Record Available"Exit SubEnd IfIf stu.Recordset.EOF Thenstu.Recordset.MoveLastEnd IfDisplayEnd If
End Sub
Private Sub CMDEXIT_Click()Unload Me
End Sub
Private Sub CMDFIRST_Click()stu.Recordset.MoveFirstDisplay
End Sub
Private Sub CMDLAST_Click()stu.Recordset.MoveLastDisplay
End Sub
Private Sub CMDNEXT_Click()stu.Recordset.MoveNextIf stu.Recordset.EOF ThenMsgBox "Last Record Is Encounted"stu.Recordset.MoveLastEnd If
Display
End Sub
Private Sub CMDPREVIOUS_Click()stu.Recordset.MovePreviousIf stu.Recordset.BOF ThenMsgBox "First Record Is Encounted"stu.Recordset.MoveFirst
End IfDisplay
End Sub
Private Sub CMDSAVE_Click()If oper = "ADD" Thenstu.Recordset.AddNewoper = ""End If stu.Recordset.Fields("rollno") = txtRollno stu.Recordset.Fields("sname") = txtNameIf Optmale.Value = True Then
stu.Recordset.Fields("sex") = "M" Else stu.Recordset.Fields("sex") = "F" End If stu.Recordset.Fields("dob") = txtdob stu.Recordset.Fields("class") = cmbClass stu.Recordset.Update ableEnd Sub
Private Sub CMDSEARCH_Click()mrollno = Val(InputBox("Enter RollNo"))stu.RefreshDo While Not stu.Recordset.EOFIf stu.Recordset.Fields("RollNo") = mrollno ThenDisplayExit SubEnd Ifstu.Recordset.MoveNextLoopMsgBox "record does not exist"
End Sub
Private Sub Form_Load()stu.RefreshIf stu.Recordset.RecordCount 0 ThenDisplayElseMsgBox "Table Is Empty"End IfableEnd SubPublic Sub Display()txtRollno = stu.Recordset.Fields("rollno")txtName = stu.Recordset.Fields("sname")If stu.Recordset.Fields("sex") = "M" Then
Optmale.Value = True Else Optfemale.Value = True End If txtdob = stu.Recordset.Fields("dob") cmbClass = stu.Recordset.Fields("class") End Sub
Public Sub clear()txtRollno.Text = ""txtName.Text = ""txtdob.Text = ""
End Sub
Private Sub txtName_keypress(KeyAscii As Integer)If KeyAscii >= 97 And KeyAscii = 65 And KeyAscii = 97 And KeyAscii < 122)) ThenKeyAscii = 0End If
End SubPublic Sub able()CMDADD.Enabled = TrueCMDSAVE.Enabled = FalseCMDCANCEL.Enabled = FalseCMDDELETE.Enabled = TrueCMDFIRST.Enabled = TrueCMDPREVIOUS.Enabled = TrueCMDNEXT.Enabled = TrueCMDLAST.Enabled = TrueCMDSEARCH.Enabled = True
End SubPublic Sub disable()
CMDADD.Enabled = FalseCMDSAVE.Enabled = TrueCMDCANCEL.Enabled = TrueCMDDELETE.Enabled = FalseCMDFIRST.Enabled = FalseCMDPREVIOUS.Enabled = FalseCMDNEXT.Enabled = FalseCMDLAST.Enabled = FalseCMDSEARCH.Enabled = False
End Sub