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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

.MovePrevious

Status
Not open for further replies.

myasin78

Programmer
Jan 26, 2004
50
US
I have two Buttons, one to select next record and one to select previous one.
the next record works, but the previous one doesn't.

the exact error i get "Operation is not allowed in this context" when i hit debug buttion .MovePrevious gets highlited in yellow which is the problem.

here is the two function that i am using.
i appreciate any help.


Private Sub cmdMoveNext_Click()
With Rs1
If Not .EOF Then
txtoutput.Text = Rs1.Fields(0)
txtpatent.Text = Rs1.Fields(1)
txtserial.Text = Rs1.Fields(2)
listbox.AddItem Rs1.Fields(0)
.MoveNext
Else
MsgBox ("End of File")
End If

End With

End Sub
Private Sub cmdMovePrev_Click()

With Rs1
If Not .BOF Then
txtoutput.Text = Rs1.Fields(0)
txtpatent.Text = Rs1.Fields(1)
txtserial.Text = Rs1.Fields(2)
.MovePrevious // here is the problem //
Else
MsgBox ("Begning of File")
End If
End With
End Sub

 
This depend on the cursor type.

Hope This Help
PH.
 
What do you mean by a cursor type.
could you be more specific.

thanks,
 
Public Rs1 As New ADODB.Recordset
Public dbConn As New ADODB.Connection
Public strSql As String

strSql = "SELECT Docket,patentno, serialno FROM Patent"
Rs1.Open strSql, dbConn
 
If you are at the first record in the recordset, you cannot move to the previous one.

-B
 
To allow browsing thru the RecordSet, your CursorType must be either adOpenDynamic (2)or adOpenKeyset (1), e.g.:
Rs1.Open strSql, dbConn, adOpenKeyset

Hope This Help
PH.
 
I am not at the begining of the record, i did go forward first, then tried to go backward.

I am also checking for .BOF

thanks anyway.
 
If this is a linked table, some ODBC sources don't support move previous.

If it's pure Access, I think you need a dynamic cursor:

Rs1.Open strSql, dbConn, adOpenDynamic

Tranman
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top