ms-access


Form.Seltop not selecting top most record


A followup to this question: Moving records from one table to another
I have a subform attached to a form. On highlighting a form and clicking something else (exit), it sends the number of rows highlighted to the main form via text box control.
Set frm = Forms!Form.[subform_subform].Form
Set rst = frm.RecordsetClone
recordStart = frm.SelTop - 1
recordEnd = recordStart + Me.SH - 1
Debug.Print Me.SH
Debug.Print recordStart
Debug.Print recordEnd
Where Me.SH is the number of rows selected. (Using http://www.tek-tips.com/viewthread.cfm?qid=1499722)
When selecting the rows from top to bottom, I get as an output for recordStart the top row that I have selected. But when I select the rows from bottom to top, I instead get the last row for recordStart. Is there a way to prevent this? The second link (as well as https://msdn.microsoft.com/en-us/library/office/ff194148.aspx) above implies that this should not happen. Is there a workaround for this?
It's you that label the records "start" and "end".
To Access there is a "Top" record selected and a "height" (count) of records selected no matter how the user (or your code) selected the records.
If you wish a different sequence of selected records, apply the needed sorting first, then select the records.
I believe I have figured it out, and I believe this is a result of the way form selections work: On exit, parametres such as .SelHeight are lost, as expected. .SelTop, however, works differently.
Say [Subform] is in datasheet view, and is a [Subform] of [Form]:
Set frm = Forms![Form].[Subform].Form
Debug.Print frm.SelTop
If you were to select the records from top to bottom, then frm.SelTop will obviously be your first selected form.
But if you were to select from bottom to top, then frm.SelTop will be your bottom row, because it was the first selected row.
That is, whatever you click first will be frm.SelTop, because for whatever reason Access passes that on as frm.SelTop.
One way to solve this, besides using a bunch of public variables (Moving records from one table to another) is to create a textbox control for .SelTop, and pass the .SelTop value to your textbox control.

Related Links

Is there a way to submit an InfoPath form to an Access database if the form was designed first?
Copying a record in VBA 2 (the new question)
Access 2007 DAO VBA Error 3381 causes objects in calling methods to “break”
ms access reports and queries
Passing variables from child to master form
Query to find the running sum of a column(qty) based on type(if 'a' add else subtract)
Can't create blank form in MS Access
How to give where condition in the select query?
What is the order of form/report events in MS Access?
moving focus from subform to main form
Alternative for Report.Load() event in Ms Access 2003
defining delimiters in vba for access
how to check if subform is opened in ms access
Access 2002 - how to Group By and Top N records in same query
Update Query - Setting new_field = existing_field
Visual Basic 6 data structures

Categories

HOME
variables
wso2
deployment
proxy
zeromq
image-processing
hashmap
raspberry-pi
win32gui
adfs
row
modx-revolution
visual-studio-2005
msp430
django-cms
karma-jasmine
swingx
amazonsellercentral
zapier
visjs
ml
errorlevel
orleans
facebook-instant-articles
dxf
sqlcipher
tooltipster
jspm
jaxb2
sql-server-2012-express
nameservers
caret
asset-pipeline
xmlreader
atl
mapbox-gl
fusionpbx
overlap
vxworks
libraries
service-discovery
hilbert-curve
dism
mesos-chronos
preconditions
total-commander
reactive-cocoa-5
rails-routing
crypt
boost-preprocessor
memory-alignment
linode
django-scheduler
query-performance
eventkit
messenger
setuptools
android-fonts
grails-tomcat-plugin
azure-sdk
google-web-starter-kit
ctest
websitepanel
rvest
dlna
apachebench
ford-fulkerson
tween
ng-animate
gui-test-framework
asp.net-dynamic-data
mdt
nsbutton
document-classification
contenttype
htmlcleaner
datagridviewcolumn
transcoding
didselectrowatindexpath
monomac
xsockets.net
chronoforms
seed
sqlperformance
hamiltonian-cycle
windows-phone-7.1.1
assembly-loading
doh
pyinotify
iphone-web-app
datareader
dentrix
asp.net-profiles
mtj
aquaticprime
putchar
multiple-languages
commodore

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App