Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using Recordset to Move First, Next,Previous and Last

Status
Not open for further replies.

azamatali

Programmer
Aug 20, 2001
50
0
0
IN
hi folks,
I am trying to implement the four buttons(FIRST, PREVIOUS, NEXT, LAST) through which the person can browse through all the records in the recordset..
But some error that this function is not allowed is given by the VB.
I am giving you the code for it.......

Dim rsall As New ADODB.Recordset

Set rsall = conn.Execute("select * from patient where patient_no like '" & pandetails1 & "' order by patient_no")

If Not rsall.EOF Then

txtpatientnumber1.Text = rsall!patient_no
txtpatientname1.Text = rsall!patient_name
txtsex1.Text = rsall!sex
txtdateofbirth1.Text = rsall!dateofbirth
End If

now the coding in the four buttons....

----FIRST
Private Sub cmdfirst_Click()
rsall.MoveFirst

txtpatientnumber1.Text = rsall!patient_no
txtpatientname1.Text = rsall!patient_name
txtsex1.Text = rsall!sex
txtdateofbirth1.Text = rsall!dateofbirth
End Sub

----LAST(WHICH IS NOT WORKING)
Private Sub cmdlast_Click()

rsall.MoveLast
txtpatientnumber1.Text = rsall!patient_no
txtpatientname1.Text = rsall!patient_name
txtsex1.Text = rsall!sex
txtdateofbirth1.Text = rsall!dateofbirth
End Sub
----PREVIOUS (WHICH IS NOT WORKING)
Private Sub cmdprevious_Click()
If Not rsall.BOF Then
rsall.MovePrevious
If rsall.BOF Then
MsgBox "First Record is Already Displayed"
End If

txtpatientnumber1.Text = rsall!patient_no
txtpatientname1.Text = rsall!patient_name
txtsex1.Text = rsall!sex
txtdateofbirth1.Text = rsall!dateofbirth
End Sub

---NEXT
Private Sub cmdNext_Click()
If Not rsall.EOF Then
rsall.MoveNext
If rsall.EOF Then
MsgBox "No Furthur Records"
GoTo leave
End If


txtpatientnumber1.Text = rsall!patient_no
txtpatientname1.Text = rsall!patient_name
txtsex1.Text = rsall!sex
txtdateofbirth1.Text = rsall!dateofbirth
End Sub

Please help me out to work this out..
 
hi,
amazing ! you have written the code properly. try giving the selectied field names instead of *.
good luck
srusti Try it for me...
 
HI SRUSTI,
i have given the field name but it's still not working it is giving the same error
This rowset does not support fetching backwardss.
 
Hi,

The 'rowset does not support fetching backwards' occurs because the default recordset is 'forward only' (which does not support fechting backwards).
Change the opening of your recordset to:

Rsall.Open "select * from patient where patient_no like '" & pandetails1 & "' order by patient_no", Conn, adOpenKeyset, adLockOptimistic

Sunaj Sunaj
'The gap between theory and practice is not as wide in theory as it is in practice'
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top