R
Ross
How can I turn on the "Num Lock" key with VBA, XP?
Thank you
Ross
Thank you
Ross
Ross said:Sorry that I didn't get back sooner.
I have had this happen before on some but not all of my programs but, as
Karen is using a form with many filters to edit data, it OFTEN (but not
consistently or predictably) turns her num locks OFF. This is very
frustrating for her and I must either:
1. Determine why Access is turning off her numlock or
2. Force it to stay on with code.
I figured the second option would be easier but I have bun unable to find
the code.
I had this happen in 2000 for a program that I wrote in MS Access 97. I
found code worked perfectly but was quite complicated. As I recall, the
code
had to identify the current operating system before it could turn the
numlocks ON or OFF.
Ross said:Send Keys? Really, Well, you have just identified what is causing it.
Here is the code.
'******************************
Private Sub txtFLTAcct_Change()
'******************************
'Set the Filter Row source
cmdClose.SetFocus
txtFLTAcct.SetFocus
SendKeys "{F2}"
Set_List_Box_Rowsource_Filters
end sub
I want to evaluated the value of a field in a form before it is updated
and
then run queries that filter and on the value of the field in the form
before
it is updated.
If I type Abc, my filters read Like "Abc" & "*".
So to eliminate the about code: How do I evaluate the value of the field
after each keystroke and have the cursor remain an the end of the field in
the for after each entry (Hence:SendKeys "{F2}") sends the cursor to the
end
of the field are re-enetering. I leave the to force the keystrokes to
update.
Ross said:Dirk,
I have come a long way from where I started but:
I did get it.
Your code almost works
I have to change your code from:
With Me.txtFLTAcct
If Len(.Text) > 0 Then
.Value = Null
Else
.Value = .Text
End If
To This:
txtFLTAcct.SetFocus
With Me.txtFLTAcct
If Len(.Text) > 0 Then
.Value = .Text
Me.txtFLTAcct.SelStart = Len(.Text)
Else
.Value = Null
End If
End With
No more sendkeys!
No more num lock problems!
Ross said:Dirk,
I had to use the setfoce because the field refreshes "on Open" the form
and
"cmdClear the form"
and I got an error that "With Me.txtFLTAcct" can't run
without focus (which makes sense).
Thanks again. This is somewhat of a powerful methology for a keystroke by
keystroke filter change.