Results 1 to 3 of 3
  1. #1
    2 Star Lounger
    Join Date
    Jul 2002
    Location
    Sacramento, CA
    Posts
    193
    Thanks
    3
    Thanked 1 Time in 1 Post
    I have a combo whose rowsource is based on a table of year values. The user would like the ability to enter, in special cases, an alpha code rather than a numeric year. He currently has four cases in which the correct year would be computed based on other form values. The idea is that a single key stoke would be a big time saver.

    So far I have been able to trap the alpha code and compute the desired value with OnKeyPress:

    stCharacter = UCase(Chr(KeyAscii))
    Select Case stCharacter
    Case "C"
    Me!CRLife = ComputeNewLife(1)
    Case "N"
    Me!CRLife =ComputeNewLife(2)
    Case "F"
    Me!CRLife = =ComputeNewLife(Me!CULife)
    Case "X"
    Me!CRLife = ComputeNewLife(Me!CULife + 1)
    End Select

    But I have not been able to keep the combo from displaying an error message informing me the alpha value is not in the list. When I close the error message and press ESC the combo box does display the expected value. I'm at a loss as to how to make it work without the error dialog and need to enter ESC. I know I can accomplish my goal with an additional command button, but the user would rather not have to tab over this each time or take his hands off the keyboard to navigate to the command button if its out of the Tab sequence.

    Appreciate any guidance,
    Marty

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts
    Try

    Code:
    Select Case stCharacter
      Case "C"
    	Me!CRLife = ComputeNewLife(1)
    	KeyAscii = 0
      Case "N"
    	Me!CRLife =ComputeNewLife(2)
    	KeyAscii = 0
      Case "F"
    	Me!CRLife = =ComputeNewLife(Me!CULife)
    	KeyAscii = 0
      Case "X"
    	Me!CRLife = ComputeNewLife(Me!CULife + 1)
    	KeyAscii = 0
    End Select
    Setting KeyAscii to 0 tells Access not to process the original keystroke.

  3. #3
    2 Star Lounger
    Join Date
    Jul 2002
    Location
    Sacramento, CA
    Posts
    193
    Thanks
    3
    Thanked 1 Time in 1 Post
    Hans,

    Thanks much works perfectly with you input.

    Marty

Posting Permissions

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