Select a number of records

T

TC

The SelTop and SelHeight form properties tell you the range of records (if
any) that are currently selected using the recordselectors down the
left-hand side of the (sub)form. (Make sure the (sub)form has the
RecordSelectors property set to true, so the record selectors are
displayed.)

Ideally, you would then like a button that used those properties to set the
relevant checkboxes. Unfortunately, clicking a button moves the focus off
the recordselectors, so this can only be done (reliably) with some
surprisingly difficult coding.

So instead of using a button, reserve a keystroke for this purpose. To
"dummy it up" & see if it will work for you:
- set the (sub)form's KeyPreview property True;
- add a KyPress event for the (sub)form;
- in that event, say:

if keyascii = asc ("z") then msgbox me.selstart & ", " & me.sellength

Now run the (sub)form, click a recordselector, shift-click another one
further down (to extend the selection), then press "z" (without the quotes).
The msgbox should display the number of the first record selected, and the
number of records selected. That information is the basis on which you could
set the relevant checkboxes.

If you think that this approach would work for you:
- pick a better key than z"; perhaps Ctrl-something?
- recode the if-test accordingly;
- replace the msgbox with code that uses "bookmarks" and RecordSetClone to
set the relevant checkboxes;
- ask again here, if you can't get that last step to work.

HTH,
TC
 
N

NHiorns

I have an Access 2000 database, the form shows
(using "Continuous Forms") a list of our customers.

On the form I have a tick box for each customer, which
when selected, you can then click on Print button and it
will print address labels for only the selected
or 'ticked' customers. This works fine.

As we have a large number of customers, the act of
ticking the boxes is laborious, therefore would like to
open a subform where I can select say customers 1 - 100
and this will then tick the select range.

Is this possible?
 
S

Sandra Daigle

You can do this in Datasheet view - using the SelTop and SelHeight
properties of the form. Since you have no command buttons in datasheet view
you have to either create a custom shortcut menu to trigger your action on
these records or put the datasheet inside a subform control. This poses some
other solvable issues.

An easier solution is often to use a multiselect listbox with a command
button that acts on the selected records.
 
N

NHiorns

I like the idea of using two combo boxes to select from
and to.

What I would ideally want to do is click a button that
opens another (smaller) form which has the from and to
selectors (using the indexed ID field). Once the from and
to have been selected, click a button on this second form
to apply and this then ticks the appropriate boxes on the
records I selected.

I can build the forms to do this but need help on the
background code .
-----Original Message-----
You can do this in Datasheet view - using the SelTop and SelHeight
properties of the form. Since you have no command buttons in datasheet view
you have to either create a custom shortcut menu to trigger your action on
these records or put the datasheet inside a subform control. This poses some
other solvable issues.

An easier solution is often to use a multiselect listbox with a command
button that acts on the selected records.

--
Sandra Daigle
[Microsoft Access MVP]
For the benefit of others please post all replies to this newsgroup.
I have an Access 2000 database, the form shows
(using "Continuous Forms") a list of our customers.

On the form I have a tick box for each customer, which
when selected, you can then click on Print button and it
will print address labels for only the selected
or 'ticked' customers. This works fine.

As we have a large number of customers, the act of
ticking the boxes is laborious, therefore would like to
open a subform where I can select say customers 1 - 100
and this will then tick the select range.

Is this possible?

.
 
S

Sandra Daigle

You could easily do this by creating an update query which has criteria that
refers to the From and To controls on your second form.

The SQL for the query would be something like:

UPDATE
cust
SET
cust.fSelect = True
WHERE
cust.Custid Between [forms]![MyForm]![cboFromCustid]
And [forms]![MyForm]![cboToCustid];



--
Sandra Daigle
[Microsoft Access MVP]
For the benefit of others please post all replies to this newsgroup.

I like the idea of using two combo boxes to select from
and to.

What I would ideally want to do is click a button that
opens another (smaller) form which has the from and to
selectors (using the indexed ID field). Once the from and
to have been selected, click a button on this second form
to apply and this then ticks the appropriate boxes on the
records I selected.

I can build the forms to do this but need help on the
background code .
-----Original Message-----
You can do this in Datasheet view - using the SelTop and SelHeight
properties of the form. Since you have no command buttons in
datasheet view you have to either create a custom shortcut menu to
trigger your action on these records or put the datasheet inside a
subform control. This poses some other solvable issues.

An easier solution is often to use a multiselect listbox with a
command button that acts on the selected records.

--
Sandra Daigle
[Microsoft Access MVP]
For the benefit of others please post all replies to this newsgroup.
I have an Access 2000 database, the form shows
(using "Continuous Forms") a list of our customers.

On the form I have a tick box for each customer, which
when selected, you can then click on Print button and it
will print address labels for only the selected
or 'ticked' customers. This works fine.

As we have a large number of customers, the act of
ticking the boxes is laborious, therefore would like to
open a subform where I can select say customers 1 - 100
and this will then tick the select range.

Is this possible?

.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top