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

Access 97 databases
'Undefined function' when using DAO QueryDef in VBA
Access 97 copying field type to other table
A query to combine multiple row values into one field in MS-Access 2003? [duplicate]
set two field primary key
Exporting Foreign Key Definitions as DDL Statements from MS Access
Access Mail Merge to different documents based on specific criteria
I just realized my database is not 1NF compliant. Is it necessary that I rebuild the tables?
MSAccess Error: Class does not support Automation or does not support expected interface
Access 2007 ReportEvents class is not firing events
Access subform in a split view parent - hide from datasheet section
2007 Split database access issues
MS-Access (Forms): allow user to enter invalid data in a bound, typed TextBox, with intent of correcting it programmatically. How?
How to add a checkbox in a form next to a query to append to another table
Access VBA - how to download XML file and enter its data into a recordset
MS-Access Calculating Percentage of Completed Tasks in a Report

Categories

HOME
client
wso2
minimum-spanning-tree
mockito
session
vmware
getelementsbytagname
at-command
setup-deployment
retrofit
opengl-es-2.0
indesign
cloudkit
spring-xd
flask-wtforms
decimal
lombok
flux
samoa
introduction
swingx
tibco-mdm
fish
apache-commons-io
info.plist
fgetcsv
fabric8
stormpath
calibre
normal-distribution
ios5
stacked
android-browser
ibpy
nxlog
acoustics
scorm
taffy
osx-mavericks
pango
multipeer-connectivity
typescript1.8
pebble-watch
worker-thread
angular-strap
angular-cache
rotativa
phishing
fody
merge-conflict-resolution
gridview-sorting
jwplayer7
lttng
sigabrt
qgraphicsview
qdialog
map-projections
riak-cs
method-parameters
mono-embedding
html-helper
has-many-through
htmlcleaner
hyprlinkr
openlaszlo
oam
.aspxauth
commoncrypto
aqtime
dexterity
jmapviewer
mylyn
django-nonrel
jquery-mobile-dialog
lcs
smtp-auth
android-hardware
robotics-studio
distutils
referrer
angularjs-controller
path-separator
word-processor
manchester-syntax
regsvr32
data-loss
mod-auth
appendto
winbugs14
sql-server-profiler
radcombobox
gamequery
routedevent
substrings
backcolor
premature-optimization
defensive-programming
dbisam
rtml

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