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

MS Access: How to Supply Parameters to a Query-Based Subform Control
Avoid duplication without using Indexed fields and 'no duplication'
how do i build a website using access 2010? [closed]
Is there a NotIn(“A”,“B”) function in VBA?
Access VBA: If Form Value <> NULL then run query else, end if. - not doing anything
ms-access: file already in use ERROR
Data from different records in one record using Access 2003
forcing EDIT of access backend database
How to collect input via a form and pass to report query in Access
sql select - order by but partial part of the field
SQL to ACCESS 2010
Select a value from a table in current DB and use a variable in Access VBA
maximum number of connections to network accessed Access database
access - properly hosting backend of access database
Generating consecutive invoice number in MS Access VBA, # restarting every year
Use Value in Word calculated with VBA in Access

Categories

HOME
bluetooth
gerrit
ngrx
lodash
relay
grep
alfresco
read-eval-print-loop
bookshelf.js
google-docs
spring-jdbc
jgroups
cross-browser
ebean
ravendb
podio
android-youtube-api
awesome-wm
iggrid
volttron
alignment
remote-access
commonmark
event-handling
opentracing
serilog
sms-gateway
dbext
swingx
google-search-api
realex-payments-api
format-specifiers
trading
pepper
nhapi
greendao
opentype
librato
socialengine
google-rich-snippets
http-get
mmenu
hexo
multilingual
dynamics-crm-2013
reportbuilder
ansible-playbook
angularjs-factory
user-controls
eclipse-scout
gzipstream
core-plot
import-from-excel
qcombobox
convertapi
angular-resource
alphabet
typescript1.8
jxcore
ifs
sqlbulkcopy
log4c
azure-virtual-network
phishing
multiple-regression
holder.js
angstrom-linux
make-install
dlna
ipconfig
pyke
cyclomatic-complexity
jmeter-maven-plugin
riak-cs
0xdbe
cakephp-3.1
appfabric-cache
ami
composite
angular-local-storage
rake-task
dd
gulp-less
flask-cors
android-radiobutton
eol
dml
didselectrowatindexpath
centos5
intentservice
uv-mapping
odata4j
bulkloader
jplaton
batterylevel
enterprisedb
smtp-auth
delphi-6
quickdialog
dice
dsn
ticoredatasync
custom-backend
psi
rfc1123
gdlib
mozilla-prism
asp.net-profiles
virtual-functions
privilege
zune
msdev
commodore
uiq3

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