iterate thru group of selected records

  • Thread starter Thread starter JamesDeckert
  • Start date Start date
J

JamesDeckert

Is there some way to iterate thru a group of selected records (using ctrl and
shift to select multiple records) contained as a subform in datasheet view.

I have a hotkey which performs some action on the current record, but would
like to perform the same action for all selected records.

thanks,
James
 
Is there some way to iterate thru a group of selected records (using ctrl and
shift to select multiple records) contained as a subform in datasheet view.

I have a hotkey which performs some action on the current record, but would
like to perform the same action for all selected records.

thanks,
James

An Update query will be a HECK of a lot easier to manage. After all, the data
is not stored in your subform nor in a datasheet, but in a Table.


John W. Vinson [MVP]
 
Even with an update query, I'd need to determine which records the user
selected to perform the update on. There is considerable logic involved using
multiple tables including accumulating a qty, or creating a new record if one
doesn't exist, prompting the user for additional info, etc. This is why I use
the info available on the form to programmatically update the records. I
reference the info on the form in this manner
Forms![CPNF]![CPNF Subform].Form![Acct#]

James
 
Even with an update query, I'd need to determine which records the user
selected to perform the update on.

Unfortunately, I don't know of any way for Access to detect which rows the
user has highlighted. There may be such a way... but I don't know it!

John W. Vinson [MVP]
 
It looks like .SelTop tells the first selected record of the block and
..SelHeight is the number of records in the selected block. This would (I
think) require me to change my way I access the records of the subform. I'd
need to use .ADO to traverse the records instead of using Forms![CPNF]![CPNF
Subform].Form![Acct#] (etc.) to access each record (unless there is a
subscript which can be added somewhere which I can use to loop through the
records - e.g. Forms![CPNF]![CPNF Subform].Form(counter)![Acct#] - but I
haven't gotten this to work.)

Thanks for the input,
James
 
Simply add another column with a check box on it, in which the user then can
select what records to operate on. you can then test for true and false in
this column and when done reset it back to false. however if you're not a
multi user environment this suggestion will not work.

Another possibility is to use the list box with multiple columns and let the
user select from that. while this box is not updateable, with multiple
columns a list box often looks very similar if not almost indistinguishable
from a continuous form.

I have a few screen shots here that uses continuous forms, and also a list
box, and I highlight some of the differences between using the two:

http://www.members.shaw.ca/AlbertKallal/Articles/Grid.htm

So consider using the list box, and a user can select multiple records from
a list box if you enable multi select ability .

You can also add a check box to the continuous form. I have an example here
on how to actually make it un-bound to function correctly, and it is a
continues form

http://www.members.shaw.ca/AlbertKallal/msaccess/msaccess.html
(Look for the multi select example the above -- well this example actually
sits a filter to a report, it would be to trivial to use the list of id's
generated in a SQL update statement to make the modifications

eg:

strSql =
"update tblTest set SomeField = SomeValue where id in (" & myfilter & ")"
currentdb.Execute strSql

"myfilter" would be the list of id's in the multi-select example I posted.
 
Back
Top