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

save position in a subform after the me.requery command?

Status
Not open for further replies.

markgx

IS-IT--Management
Joined
Nov 27, 2002
Messages
3
Location
GB
I have some code that requires a requery of the base data of a subform. The problem is that if the subform is in a windows and the vertical scroll has been used to go to a certain record, after the update the subform jumps back to the first record. I would like to do a requery but not alter the position of the records in the subform, is that possible?

I have tried using code to jump back to the correct record but the screen still 'jumps about', because on selection of the correct record the record is positioned at the bottom of the subform as opposed to it's original position.

Any ideas?

Thanks
Mark
 
You the Bookmark and LastModified properties to return to a changed or added record.

The following example was obtained from Microsoft (
Sub LastModifiedX()

Dim dbsNorthwind As Database
Dim rstEmployees As Recordset
Dim strFirst As String
Dim strLast As String

Set dbsNorthwind = OpenDatabase("Northwind.mdb")
Set rstEmployees = _
dbsNorthwind.OpenRecordset("Employees", _
dbOpenDynaset)

With rstEmployees
' Store current data.
strFirst = !FirstName
strLast = !LastName
' Change data in current record.
.Edit
!FirstName = "Julie"
!LastName = "Warren"
.Update
' Move current record pointer to the most recently
' changed or added record.
.Bookmark = .LastModified
Debug.Print _
"Data in LastModified record after Edit: " & _
!FirstName & " " & !LastName

' Restore original data because this is a demonstration.
.Edit
!FirstName = strFirst
!LastName = strLast
.Update

' Add new record.
.AddNew
!FirstName = "Roger"
!LastName = "Harui"
.Update
' Move current record pointer to the most recently
' changed or added record.
.Bookmark = .LastModified
Debug.Print _
"Data in LastModified record after AddNew: " & _
!FirstName & " " & !LastName

' Delete new record because this is a demonstration.
.Delete
.Close
End With

dbsNorthwind.Close

End Sub


However, there are some problems with the Bookmark and LastModifed property, check out Microsoft Knowledge Base Article - 238134 and Microsoft Knowledge Base Article - 224932 for more detail. Anthony J. DeSalvo
President - ScottTech Software
"Integrating Technology with Business"
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top