Results 1 to 5 of 5
  1. #1
    5 Star Lounger
    Join Date
    Nov 2001
    Location
    Toronto Canada
    Posts
    920
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Nullify KeyDown (A2K)

    I use the following code to manipulate data on a record by record basis. I visually display a text box description of the function keys so that the user knows which one to press in order to process their actions. These text box function keys are identified as [txtFuncKey02], [txtFuncKey03], [txtFuncKey04], and [txtFuncKey05]. Depending on the situation they may only need to do the F2 Action or the F2 and F3 Actions.

    As they use each of these, the visually displayed function key ( [txtFuncKey02] ), etc. disappears from the screen by testing on its' related Date field:

    If Me.txt_F02_Date_Time_Date > 0 Then
    Me![txtFuncKey02].Visible = False
    Else
    Me![txtFuncKey02].Visible = True
    End If

    All of this works well and that's a good thing.

    However, even though the displayed Function Key has disappeared from the screen, they could physically still hit that Function Key and change the previous values.

    And that is not a good thing.

    So, the question is:

    Can I nullify the physical Function Key on a record by record basis?


    '==============================================
    Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
    '==============================================
    If KeyCode = vbKeyF2 Then
    Me.txt_F02_Date_Time_Date = Now
    Me.cbo_F02_UserId.SetFocus
    Me.cbo_F02_UserId.Dropdown
    Me.txt_F02_Date_Time_Date.Visible = True
    Me.StartBox.Visible = False
    KeyCode = 0
    End If
    '
    If Me.txt_F02_Date_Time_Date > 0 Then
    Me![txtFuncKey02].Visible = False
    Else
    Me![txtFuncKey02].Visible = True
    End If
    '==============================================
    If KeyCode = vbKeyF3 Then
    Me.txt_F03_Date_Time_Date = Now
    Me.cbo_F03_UserId.SetFocus
    Me.cbo_F03_UserId.Dropdown
    Me.HoldBox.Visible = False
    KeyCode = 0
    End If
    '
    If Me.txt_F03_Date_Time_Date > 0 Then
    Me![txtFuncKey03].Visible = False
    Else
    Me![txtFuncKey03].Visible = True
    End If
    Cheers,
    Andy

  2. #2
    Super Moderator
    Join Date
    Aug 2001
    Location
    Evergreen, CO, USA
    Posts
    6,623
    Thanks
    3
    Thanked 60 Times in 60 Posts

    Re: Nullify KeyDown (A2K)

    To prevent a function key from being hit twice, you will need to expand your code to capture the keystroke and use a flag that indicates whether it has already been hit once. You probably should make it a series of public values that you can set or reset from anywhere in your form.

    The bigger question however is why you want to use Function keys to do this sort of thing. My suspicion is that you are trying to emulate an older DOS interface as people don't want to learn how to use a graphical user interface. Our experience says that's not a good thing to do. We faced this problem 11 years ago on a project - we were asked to duplicate their existing user interface as best we could. We did, but spent lots of time doing it because we had to write lots of code. Within a year, we were asked to redesign it to remove that capability and add a number of others. I've since spoken to a number of other developers who had the same experience. You might consider using command buttons, which can emulate that sort of thing by turning on and off the enabled property. If a command button has focus, all the user needs to do is hit Enter and the button fires.

    Another reason for reconsidering is that Access has implicit functions assigned to most of the function keys in certain situations. For example, if you are working on a bound form and hit F5, the focus is moved to the record navigation area - assuming you are displaying it. A user who knows that may try to use that capability and cause unexpected results.
    Wendell

  3. #3
    5 Star Lounger
    Join Date
    Nov 2001
    Location
    Toronto Canada
    Posts
    920
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Nullify KeyDown (A2K)

    Wendell,

    Your answer was as I expected. You are 100% accurate in surmising that this is a rewrite. In it's previous life it was a dos-Based Q & A database and is still being used on a daily basis. It is an intricate, convuluted, but extremely powerful system. The person that wrote the system managed to get the whole company's procedures, and I mean everything, into one, eight page form. It is unbelievably clever. That's the good news. The bad and sad news is that he died suddenly of a heart attack while on the job. I don't think I need to tell you how much of it was documented. You're right. Nada!

    What I'm going to do is show them a copy of my posting and your response which so hits the nail on the head. Thank you again for your wise words,
    Cheers,
    Andy

  4. #4
    Super Moderator
    Join Date
    Aug 2001
    Location
    Evergreen, CO, USA
    Posts
    6,623
    Thanks
    3
    Thanked 60 Times in 60 Posts

    Re: Nullify KeyDown (A2K)

    You might consider converting to a tabbed form - we use those extensively with subforms that are dynamically linked. Also you will probably at some point need to normalize the data for Access to work with it effectively. Q&A is still basically a flat-file database so if your table structure looks like the Q&A structure, you will see some significant inefficiencies. Good luck, and by the way, document how it works! <img src=/S/sad.gif border=0 alt=sad width=15 height=15>
    Wendell

  5. #5
    5 Star Lounger
    Join Date
    Nov 2001
    Location
    Toronto Canada
    Posts
    920
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Nullify KeyDown (A2K)

    Wendell,

    They have had no problem with my taking apart their system and making it look a little more "modern". And they are well aware of the fact that having all of their coding eggs in one basket, as in the past, is not a good thing. All data has been pulverized, sanitized, and normalized until the electronic cows come home. The only thing they wanted me to consider was to try and keep their little processing fingers off the mouse as much as possible.

    Strangely, and really weird, during our initial interview with respect to taking on the system, I alluded to the fact that I create what I refer to as DDD ( Drop Dead Documentation ) as I go along, just in case. I wasn't aware at the time of how the need for the rewrite had come about. I think it really hit home. I did apologize later for my inserting my foot in my mouth, but they were actually impressed with the concept and were in total agreement to my approach. Ouch! Anyway, thanks again for your advice. Maybe those looking over our shoulders will learn from this as I always do,
    Cheers,
    Andy

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •