Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
hi friend
i am sending a prog in VB6.0. I want to see total number of records in the form of VB. In backend i am using Access
i want a button on form that can tell
me the no of records existing in the table.
Advance Thanks for helping----
Dim con As New Connection
Dim rs As New Recordset
Dim rsempno As New ADODB.Recordset
Dim rono As Integer
Dim b As BooleanPrivate Sub Command1_Click()
On Error Resume Next
rs.MoveNext
If rs.EOF Then
rs.MoveLast
MsgBox "end of file"
End If
getdEnd Sub
Private Sub Command2_Click()
rs.MoveLast
getd
End SubPrivate Sub Command3_Click()
rs.MovePreviousIf rs.BOF Then
rs.MoveFirst
MsgBox "beg of file"
End If
getd
End SubPrivate Sub Command4_Click()
rs.MoveFirst
getd
End SubPrivate Sub Command5_Click()
On Error GoTo last
If Text1.Text = "" And Text2.Text = "" And Text3.Text = "" Then
MsgBox "Enter the rollno in the textbox"
Exit Sub
End If
rs.AddNew
rs(0) = Text1.Text
rs(1) = Text2.Text
rs(2) = Val(Text3.Text)
rs.Update
MsgBox "record is updated"
last:
If Err.Number = -2147217887 Then
MsgBox Err.Description
End If
End SubPrivate Sub Command6_Click()
b = True
Text1.Text = ""
Text2 = ""
Text3 = ""
Text1.SetFocus
End SubPrivate Sub Command7_Click()
On Error GoTo last
If MsgBox("Are you sure you want to delete a record", vbYesNo + vbCritical, "Deletion") = vbYes Then
If rs.RecordCount = -1 Then
Text1.Text = ""
MsgBox "No more record exists in the database", vbInformation
End If
rs.Delete
rs.MoveNext
rs.MovePrevious
getd
MsgBox "Record is deleted"
End Iflast:
If Err = 3021 Then
MsgBox "No more record exists", vbInformation
End IfEnd Sub
Private Sub Command8_Click()
If Text1.Text = "" Then
MsgBox "plz select the record for updation"
Exit Sub
End If
'rono = Text1.Text
'rs.Open "select * from std where rollno = " & rono & " ", con, 2, 3rs(1) = Text2.Text
rs(2) = Val(Text3.Text)rs.Update
MsgBox "record is updated"End Sub
Private Sub Form_Load()
On Error GoTo last:
con.Open "provider = microsoft.jet.oledb.4.0;data source = " & App.Path & "\pp.mdb "
rs.Open "select * from std", con, 2, 3
getdlast:
If Err = 3021 Then
MsgBox "No record exists in the table", vbInformation
End If
End Sub
Private Sub getd()
Text1 = rs(0)
Text2 = rs(1) & ""
Text3 = rs(2) & ""
End Sub
Private Sub Text2_GotFocus()On Error GoTo last
Set rsempno = con.Execute("select rollno from std where rollno = " & Val(Text1.Text) & " ")If Val(Text1.Text) = rsempno("rollno") And b = True Then
MsgBox "this record already exist"
Text1.SetFocus
End Iflast:
If Err.Number = 3021 Then
End If
End Sub

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |