Hi Proko,
Not sure that this is the best or only answer but you could possibly use something like the following on every control into which the user could enter data. NOTE that Dim firstKeyPressed As Boolean is in the declarations area at the top of the form. That way it retains its value all the time the form is open and its default value is False when the form opens. (I put the msgbox in for testing only.)
Option Compare Database Option Explicit Dim firstKeyPressed As Boolean 'Default value is false
Private Sub Text0_KeyPress(KeyAscii As Integer)
If firstKeyPressed = False Then firstKeyPressed = True MsgBox "Key pressed is " & Chr(KeyAscii) End If
End Sub
You could even consider disabling all controls but the one with the above code and then enable the remaining controls after the first key stroke.
-- Regards,
OssieMac
"Proko" wrote:
[Quoted Text] > What form event do I use to trap a users first keystroke on an unbound form? > I have placed breaks on KeyUp, KeyDown and KeyPress but none of the events > seem to trigger with a keystroke. If I could work this out I would then moove > on to the following problemwhich someone may be able to help me with also. > I have declared as public fFirstKeyStroke as Boolean, I'm not sure how to > set its initial value. I thought maybe Const fFirstKeyStroke = True, but I > get an error message when the form loads. > My plan is to log the first keystroke event in a temporary table to be saved > to a permanent audit table once the record is saved. Any help would be > greatly appreciated.
|