Determine If Record Selector is selected

D

DevlinM

Hello All,

I understand how to use the SelTop, SelHeight, etc...

The problem is that those properties do not indicate whether or not the
record selector in a data-sheet or continuous form is actually selected.

So the question is; is there a way to determine if the record selector
itself has been selected?

Any help here is appreciated.

Devlin
 
T

Tom van Stiphout

On Fri, 26 Mar 2010 20:29:01 -0700, DevlinM

Why would you want to know?
I'm not sure there is anything to be gained from that.

-Tom.
Microsoft Access MVP
 
D

DevlinM

Because certain Access operations can't be performed if just the columns are
selected, such as "Delete." That's the simple of it.

Going a little deeper... When a form is opened as acDialog, certain short
cut key operations become disabled, (e.g. [ctl] + [-] = Delete, [ctl] + [ ' ]
= Copy Previous Value, etc..) I want to write code to handle these keys and
perform the disabled operations. This seems simple at first, but there are a
number of obscure considerations involved. So in the case of "Delete," in a
normal window mode, Access will not delete a record unless the record
selector is selected. I need to be able to operate just the same when the
window mode is acDialog.
 
T

Tom van Stiphout

On Sat, 27 Mar 2010 06:40:01 -0700, DevlinM

I see. Generally, if the user uses a keystroke at an inappropriate
time, Access will complain or simply do nothing. Couldn't you do the
same? So rather than writing:
if RecordSelectorSelected() then
RunCommand acCmdDeleteRecord
endif
You can write:
RunCommand acCmdDeleteRecord

I'm assuming you're using an AutoKeys macro?

But to answer your direct question: no, I don't think there is a
built-in way to know that the recordselector is selected. You could go
to extremes like: "a field lost focus, but no other one gained focus,
so focus must be on the recordselector" but that would likely fail in
several ways (e.g. focus is on navigation buttons). You may be
fighting the windmills here.

-Tom.
Microsoft Access MVP

Because certain Access operations can't be performed if just the columns are
selected, such as "Delete." That's the simple of it.

Going a little deeper... When a form is opened as acDialog, certain short
cut key operations become disabled, (e.g. [ctl] + [-] = Delete, [ctl] + [ ' ]
= Copy Previous Value, etc..) I want to write code to handle these keys and
perform the disabled operations. This seems simple at first, but there are a
number of obscure considerations involved. So in the case of "Delete," in a
normal window mode, Access will not delete a record unless the record
selector is selected. I need to be able to operate just the same when the
window mode is acDialog.

Tom van Stiphout said:
On Fri, 26 Mar 2010 20:29:01 -0700, DevlinM

Why would you want to know?
I'm not sure there is anything to be gained from that.

-Tom.
Microsoft Access MVP


.
 
D

DevlinM

To further add... When the key combination [ctl] + [-] is used, Access
automatically selects the record via the record selector, then begins
performing the delete operations. This would be the same as if the user
selects the record selector manually, then presses the key [Delete].
 
S

Stuart McCall

DevlinM said:
Because certain Access operations can't be performed if just the columns
are
selected, such as "Delete." That's the simple of it.

Going a little deeper... When a form is opened as acDialog, certain short
cut key operations become disabled, (e.g. [ctl] + [-] = Delete, [ctl] +
[ ' ]
= Copy Previous Value, etc..) I want to write code to handle these keys
and
perform the disabled operations. This seems simple at first, but there
are a
number of obscure considerations involved. So in the case of "Delete," in
a
normal window mode, Access will not delete a record unless the record
selector is selected. I need to be able to operate just the same when the
window mode is acDialog.

Just tested this & it works (in acDialog mode):

With DoCmd
.RunCommand acCmdSelectRecord
.RunCommand acCmdDeleteRecord
End With
 
D

DevlinM

Your solution is somewhat correct.

As I was saying earlier, in the instance where the form is opened as
acWindowNormal, the key combination for deleting would first select the
record (record selector=ON), then it would begin the Delete operations and so
on.

In the acDialog instance, that key combination is disabled. Therefore, what
I need to be able to do is, as in the acWindowNormal condition, select the
entire record (record selector=ON), then run the command delete.

So the code looks something like this

Select Case KeyCode & Shift
Case 189 & 2, 109 & 2 ' [ctl] + [ - ]
RunCommand acCmdSelectRecord
RunCommand acCmdDeleteRecord
Case Else
Exit Sub
End Select

However, the problem is this... In the acWindowNormal instance, a user can
select multiple records and perform the key combination. Somehow Access
recognizes that the records are selected (record selectors=ON) and performs
operations as appropriate.

My current solution will only delete the current record.

I'm just being picky and trying to operate exactly the same as Access
operates in the normal instance.

I can perform this in a similar fashion and delete the records myself in
code based on the SelTop, SelHeight, etc.. The difference is that if the
user selects all the columns, but the record selector isn't selected,
SelWidth returns the same value regardless of record selector value. In the
normal instance, Access will not delete records if only the columns are
selected. That !@#$% selector has to be selected.

Oh well... I'll keep looking for a solution.

Thanks
Devlin

Tom van Stiphout said:
On Sat, 27 Mar 2010 06:40:01 -0700, DevlinM

I see. Generally, if the user uses a keystroke at an inappropriate
time, Access will complain or simply do nothing. Couldn't you do the
same? So rather than writing:
if RecordSelectorSelected() then
RunCommand acCmdDeleteRecord
endif
You can write:
RunCommand acCmdDeleteRecord

I'm assuming you're using an AutoKeys macro?

But to answer your direct question: no, I don't think there is a
built-in way to know that the recordselector is selected. You could go
to extremes like: "a field lost focus, but no other one gained focus,
so focus must be on the recordselector" but that would likely fail in
several ways (e.g. focus is on navigation buttons). You may be
fighting the windmills here.

-Tom.
Microsoft Access MVP

Because certain Access operations can't be performed if just the columns are
selected, such as "Delete." That's the simple of it.

Going a little deeper... When a form is opened as acDialog, certain short
cut key operations become disabled, (e.g. [ctl] + [-] = Delete, [ctl] + [ ' ]
= Copy Previous Value, etc..) I want to write code to handle these keys and
perform the disabled operations. This seems simple at first, but there are a
number of obscure considerations involved. So in the case of "Delete," in a
normal window mode, Access will not delete a record unless the record
selector is selected. I need to be able to operate just the same when the
window mode is acDialog.

Tom van Stiphout said:
On Fri, 26 Mar 2010 20:29:01 -0700, DevlinM

Why would you want to know?
I'm not sure there is anything to be gained from that.

-Tom.
Microsoft Access MVP


Hello All,

I understand how to use the SelTop, SelHeight, etc...

The problem is that those properties do not indicate whether or not the
record selector in a data-sheet or continuous form is actually selected.

So the question is; is there a way to determine if the record selector
itself has been selected?

Any help here is appreciated.

Devlin

.
.
 
D

DevlinM

Ok, I think I have figured this out. There are two commands available. The
first is Delete and the other DeleteRecord. Delete handles multiple
selections and DeleteRecord handles an individual record. Delete recognizes
if the entire record is selected, not just the columns. Just FYI for any and
all who might be interested.

Thanks!

Tom van Stiphout said:
On Sat, 27 Mar 2010 06:40:01 -0700, DevlinM

I see. Generally, if the user uses a keystroke at an inappropriate
time, Access will complain or simply do nothing. Couldn't you do the
same? So rather than writing:
if RecordSelectorSelected() then
RunCommand acCmdDeleteRecord
endif
You can write:
RunCommand acCmdDeleteRecord

I'm assuming you're using an AutoKeys macro?

But to answer your direct question: no, I don't think there is a
built-in way to know that the recordselector is selected. You could go
to extremes like: "a field lost focus, but no other one gained focus,
so focus must be on the recordselector" but that would likely fail in
several ways (e.g. focus is on navigation buttons). You may be
fighting the windmills here.

-Tom.
Microsoft Access MVP

Because certain Access operations can't be performed if just the columns are
selected, such as "Delete." That's the simple of it.

Going a little deeper... When a form is opened as acDialog, certain short
cut key operations become disabled, (e.g. [ctl] + [-] = Delete, [ctl] + [ ' ]
= Copy Previous Value, etc..) I want to write code to handle these keys and
perform the disabled operations. This seems simple at first, but there are a
number of obscure considerations involved. So in the case of "Delete," in a
normal window mode, Access will not delete a record unless the record
selector is selected. I need to be able to operate just the same when the
window mode is acDialog.

Tom van Stiphout said:
On Fri, 26 Mar 2010 20:29:01 -0700, DevlinM

Why would you want to know?
I'm not sure there is anything to be gained from that.

-Tom.
Microsoft Access MVP


Hello All,

I understand how to use the SelTop, SelHeight, etc...

The problem is that those properties do not indicate whether or not the
record selector in a data-sheet or continuous form is actually selected.

So the question is; is there a way to determine if the record selector
itself has been selected?

Any help here is appreciated.

Devlin

.
.
 
D

DevlinM

Yes it does... Thanks. Howerver, be sure to see the last posting.

Stuart McCall said:
DevlinM said:
Because certain Access operations can't be performed if just the columns
are
selected, such as "Delete." That's the simple of it.

Going a little deeper... When a form is opened as acDialog, certain short
cut key operations become disabled, (e.g. [ctl] + [-] = Delete, [ctl] +
[ ' ]
= Copy Previous Value, etc..) I want to write code to handle these keys
and
perform the disabled operations. This seems simple at first, but there
are a
number of obscure considerations involved. So in the case of "Delete," in
a
normal window mode, Access will not delete a record unless the record
selector is selected. I need to be able to operate just the same when the
window mode is acDialog.

Just tested this & it works (in acDialog mode):

With DoCmd
.RunCommand acCmdSelectRecord
.RunCommand acCmdDeleteRecord
End With


.
 
S

Stuart McCall

DevlinM said:
Ok, I think I have figured this out. There are two commands available.
The
first is Delete and the other DeleteRecord. Delete handles multiple
selections and DeleteRecord handles an individual record. Delete
recognizes
if the entire record is selected, not just the columns. Just FYI for any
and
all who might be interested.

Thanks!

Glad you got it working, and thanks for sharing re Delete & DeleteRecord. I
wasn't aware of that.
 

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