17. september 2002 - 12:06Der er
22 kommentarer og 1 løsning
.MoveNext og .MovePrevious
Hej Guru'er Jeg har et problem, jeg har et recordset som jeg i min kode har behov for at bladre i mellem. .Movenext virker fint, men når jeg forsøger at .moveprevious for jeg at vide at det ikke er muligt i denne sammenhæng.
Er der nogen der kan forklare sammenhængen?
Databasen er Access, og jeg bruger ADO til at lave min forbindelse.
The recordset placeholder is an object variable that represents an open Recordset object.
Remarks
Use the Move methods to move from record to record without applying a condition.
Caution If you edit the current record, be sure you use the Update method to save the changes before you move to another record. If you move to another record without updating, your changes are lost without warning.
When you open a Recordset, the first record is current and the BOF property is False. If the Recordset contains no records, the BOF property is True, and there is no current record.
If the first or last record is already current when you use MoveFirst or MoveLast, the current record doesn't change.
If you use MovePrevious when the first record is current, the BOF property is True, and there is no current record. If you use MovePrevious again, an error occurs, and BOF remains True.
If you use MoveNext when the last record is current, the EOF property is True, and there is no current record. If you use MoveNext again, an error occurs, and EOF remains True.
If recordset refers to a table-type Recordset (Microsoft Jet workspaces only), movement follows the current index. You can set the current index by using the Index property. If you don't set the current index, the order of returned records is undefined.
Important You can use the MoveLast method to fully populate a dynaset- or snapshot-type Recordset to provide the current number of records in the Recordset. However, if you use MoveLast in this way, you can slow down your application's performance. You should only use MoveLast to get a record count if it is absolutely necessary to obtain an accurate record count on a newly opened Recordset. If you use the dbRunAsync constant with MoveLast, the method call is asynchronous. You can use the StillExecuting property to determine when the Recordset is fully populated, and you can use the Cancel method to terminate execution of the asynchronous MoveLast method call.
You can't use the MoveFirst, MoveLast, and MovePrevious methods on a forward-only–type Recordset object.
To move the position of the current record in a Recordset object a specific number of records forward or backward, use the Move method.
medions: Jeg har behov for at bladre tilbage og frem i mit recordset.
Okay det vil sige at hvis jeg har
dim SmartRecordset as recordset set SmartRecordset = adoconn.execute "select * from Strotabel"
så vil recordset.movenext virke men ikke recordset.moveprevious Men hvis jeg skriver dim SmartRecordset as adodb.recordset burde det virke? (hvis ja så virker det ikke)
lidt kode: I keypress evented på en textbox(Bruges til at brugeren skal bladre til han har fundet det han søger.
Select Case KeyCode Case 119 'F8 With localDBclass .RecivRecordset.MoveNext End With Case 120 'F9 With localDBclass .RecivRecordset.MovePrevious End With
Case Else
End Select
I min klasse har jeg: ’under option explicit Dim LocalDBcon As New Connection Public RecivRecordset As ADODB.Recordset
Den function der definere recordsettet Set RecivRecordset = LocalDBcon.Execute("select * from table")
<Snip> dim SmartRecordset as recordset set SmartRecordset = new ADODB.recordset with SmartRecordset .cursortype = adOpenKeyset .locktype = adLockReadOnly (adLockOptimistic, hvis der skal redigeres)
Dim LocalDBcon As New ADODB.Connection LocalDBcon.Open "Driver={Microsoft Access Driver (*.mdb)};DBQ=" & App.Path & "\system.mdb"
Public SmartRecordset As New ADODB.Recordset SmartRecordset.CursorType = adOpenKeyset SmartRecordset.LockType = adLockReadOnly Set SmartRecordset = LocalDBcon.Execute("select * from Reciver where Zipcode = '" & ZipCode & "' and Adr1 like '" & RecivStreet & "%'")
Dim LocalDBcon As New ADODB.Connection LocalDBcon.Open "Driver={Microsoft Access Driver (*.mdb)};DBQ=" & App.Path & "\system.mdb"
Public SmartRecordset As New ADODB.Recordset SmartRecordset.CursorType = adOpenKeyset SmartRecordset.LockType = adLockReadOnly SmartRecordset.Open "select * from Reciver where Zipcode = '" & ZipCode & "' and Adr1 like '" & RecivStreet & "%'", LocalDBCon
Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.