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
.
.