I am using these codes but i am not able to navigate the records...What should i do?
[code=vb]
Private Sub cmdfirst_Click( Index As Integer)
rsnew3.Open "select * from _____", c, adOpenDynamic
rsnew3.MoveFirs t
If rsnew3.State = adstaticopen Then rsnew3.Close
Set rsnew3 = Nothing
End Sub
Private Sub cmdlast_Click(I ndex As Integer)
rsnew3.Open "select * from ______", c, adOpenDynamic
rsnew3.MoveLast
If rsnew3.State = adstaticopen Then rsnew3.Close
Set rsnew3 = Nothing
End Sub
Private Sub cmdnext_Click(I ndex As Integer)
rsnew3.Open "select * from _______", c, adOpenDynamic
If Not rsnew3.EOF Then rsnew3.MoveNext
rsnew3.MoveLast
If rsnew3.State = adstaticopen Then rsnew3.Close
Set rsnew3 = Nothing
End Sub
Private Sub cmdprev_Click(I ndex As Integer)
rsnew3.Open "select * from ______", c, adOpenDynamic
If Not rsnew3.BOF Then rsnew3.MovePrev ious
rsnew3.MoveFirs t
If rsnew3.State = adstaticopen Then rsnew3.Close
Set rsnew3 = Nothing
End Sub
Private Sub Form_Load()
Dim cs As String
c.Open ("Provider=Micr osoft.Jet.OLEDB .4.0;Data Source=________ .mdb;Persist Security Info=false")
RSNew2.Open "select * from ______", c, adOpenDynamic
Me.Text1.Text = RSNew2(2)
Me.Text2.Text = RSNew2(3)
If RSNew2.State = adstaticopen Then RSNew2.Close
Set RSNew2 = Nothing
End Sub
[/code]
I am not getting any error also...
can anybody pls help????
Last edited by debasisdas; Mar 5 '08, 08:29 AM.
Reason: added code=vb tags
You need not open so many recordsets in Navigation buttons..
Declare a Recordset Form Level.. And Move and display results..
Some thing like this :
[code=vb]
Option explicit
Dim RST As New ADODB.Recordset
Private Sub cmdfirst_Click( Index As Integer)
RST.MoveFirst
Call ShowRecs
End Sub
Private Sub cmdlast_Click(I ndex As Integer)
RST.MoveLast
Call ShowRecs
End Sub
Private Sub cmdnext_Click(I ndex As Integer)
RST.MoveNext
If RST.BOF Then
RST.MoveLast
End If
Call ShowRecs
End Sub
Private Sub cmdprev_Click(I ndex As Integer)
RST.MovePreviou s
If RST.BOF Then
RST.MoveFirst
End If
Call ShowRecs
End Sub
Private Sub Form_Load()
Dim cs As String
c.Open ("Provider=Micr osoft.Jet.OLEDB .4.0;Data Source=________ .mdb;Persist Security Info=false")
Set RST= Nothing
RST.Open "select * from ______", c, adOpenDynamic
If Not RST.EOF Then
Call ShowRecs
End If
End Sub
Private Sub ShowRecs()
Me.Text1.Text = RST(2)
Me.Text2.Text = RST(3)
End Sub
[/code]
Some Fine tuning is required, but gives you the Basic Idea..
and why u have closed the recordset in form load itself.
Hi ..
I changed the record set from rsnew3 to rsnew2.. And removed the line which closed the record set in lode itself .. But now i am getting error ..
The error is:::
RUN TIME ERROR::3705
OPERATION IS NOT ALLOWED WHEN OBJECT IS OPEN...IN
Private Sub cmdprev_Click(I ndex As Integer)
Hi
I implemented the same code in my other program.. But there i am getting an error .. Error is ::: Compile error::
Procedure declaration does not match description of event or procedure having the same name...
What does it mean and what should i do ????
In this for, your Navigation buttons have got "Index" (Control array)
and in other forms, they may not have Index...
In New form, Remove the entire code of navigation buttons
Copy code from Each button, and double click the button and paste in new form..
Hi All..
Now i am trying to implement navigation by using control array.. Here is my code ..
[code=vb]
Option Explicit
Dim c As New ADODB.Connectio n
Dim cm As ADODB.Command
Dim rs1 As New ADODB.Recordset
Private Sub cmdnav_Click(In dex As Integer)
Select Case Index
Case 0
rs1.movefirst
Call ShowRecs
Case 1
rs1.movepreviou s
Call ShowRecs
Case 2
rs1.movenext
Call ShowRecs
Case 3
rs1.movelast
Call ShowRecs
End Select
End Sub
Private Sub Form_Load()
Dim cs As String
Dim RSNew As New ADODB.Recordset
Dim RSNew1 As New ADODB.Recordset
c.Open ("Provider=Micr osoft.Jet.OLEDB .4.0;Data Source=______.m db;Persist Security Info=false")
End Sub
Private Sub ShowRecs()
rs1.Open "select * from _______", c, adOpenDynamic
Me.Text1.Text = rs1(3)
End Sub
Private Sub setnavigationbu tton(bval As Boolean)
Dim i As Integer
For i = 0 To 3
cmdnav(i).Enabl ed = bval
Next
End Sub
[/code]
error i am getting is
ERROR 3704 ,,,, OPERATION IS NOT ALLOWED WHWN OBJECT IS CLOSED...
Private Sub ShowRecs()
rs1.Open "select * from setting", c, adOpenDynamic<-------HERE
Last edited by debasisdas; Mar 7 '08, 06:33 AM.
Reason: added code=vb tags
[code=vb]
Private Sub ShowRecs()
Set rs1 = Nothing
rs1.Open "select * from setting", c, adOpenDynamic
End Sub
[/code]
This is a Quick and Dirty Solution.... but works
The Error is Because, you have a Recordset rs1 in the project, where you have opened and not Closed.. It's always good practice to close the recset after use.. (Or else close it in FormUnload event)
[code=vb]
Private Sub ShowRecs()
Set rs1 = Nothing
rs1.Open "select * from setting", c, adOpenDynamic
End Sub
[/code]
This is a Quick and Dirty Solution.... but works
The Error is Because, you have a Recordset rs1 in the project, where you have opened and not Closed.. It's always good practice to close the recset after use.. (Or else close it in FormUnload event)
Regards
Veena
Hi i tried it.. Now i am not getting any error but the navigation buttons are not responding.. I guess i have gone wrong in coding the control array..Can you just check out and tell me where i have gone wrong ??
Write the codes Neatly.. You have created a mess.. Dont Unnecessarily open recset and use so many Variables..
INDENT Properly..
Any way try this :
[code=vb]
Option Explicit
Dim c As New ADODB.Connectio n
Dim cm As ADODB.Command
Dim rs1 As New ADODB.Recordset
Private Sub cmdnav_Click(In dex As Integer)
Select Case Index
Case 0
rs1.movefirst
Call ShowRecs
Case 1
rs1.movepreviou s
Call ShowRecs
Case 2
rs1.movenext
Call ShowRecs
Case 3
rs1.movelast
Call ShowRecs
End Select
End Sub
Private Sub Form_Load()
c.Open ("Provider=Micr osoft.Jet.OLEDB .4.0;Data Source=______.m db;Persist Security Info=false")
Set rs1 =Nothing
rs1.Open "select * from _______", c, adOpenDynamic
If Not rs1.EOF Then
rs1.MoveFirst
Call ShowRecs
Call setnavigationbu tton(True)
Else
Call setnavigationbu tton(False)
End If
End Sub
Private Sub ShowRecs()
Me.Text1.Text = rs1(3)
End Sub
Private Sub setnavigationbu tton(bval As Boolean)
Dim i As Integer
For i = 0 To 3
cmdnav(i).Enabl ed = bval
Next
End Sub
[/code]
Comment