Ascii

ajetrumpet

Banned
Local time
Yesterday, 18:04
Joined
Jun 22, 2007
Messages
5,638
All,

Does anyone have a good resource for an ASCII table? I seem to have read a post on here a while back that gave a great link for it, but I can't find it anymore! Anyway, I need the integer for the "Enter" key. Is there one? Thanks!
 
First hit on Google. More on Google if you prefer something else.

That said, I am pretty sure there's no ASCII code for "Enter". If you want to capture newline or something like that, see if vbCrLf can help you out.
 
Capture a new line Banana?

I have tried Chr$(13), Chr(13) and vbCr(13) in the declaration of the KeyPress. Is this the wrong format? Brackets needed? thanks!

(Tried searching on google, could not find a table with "enter" in it)

If I can't do this, can I disable the key completely?
 
Chr(10) returns a linefeed character; Chr(13) returns a carriage return character; The two-character string Chr(13) & Chr(10) returns a Windows newline
 
You can capture the press of the enter key on the key down event. It will have a value of 13. Try something like below in the keydown event

if keycode= 13 then Me.Undo
 
Have you looked at vbKeyReturn under Keycode Constants in VBA Help?
 
Bob,
Where did you get that funny picture that you now have as an avatar? :p:p:D
 
I'm surprised you got him to hold still long enough to snap a picture. :p
 
Banana,

I have no idea how to read the table in the link you gave me. I don't see a symbol, or number for the enter key.

Everyone Else,

I am trying to completely disable the enter key, either while a certain form is active, or at all times when the database file is open.

I have no idea how to do this, and I have read the VBA help regarding the const.'s, but it only seems to be giving references to the them, and the const. values that are associated. Keith's suggestion does not work, in terms of preventing the addition of a record to a table. I thought it would be something like this...
Code:
If KeyCode (constant) = vbkeyreturn (or equiv. value) then

  me.undo
But this just performs an action (if the coding is correct, that is) when the Enter key is pressed. I'm not looking for this. I want to shut the key's function off completely. Am I asking the impossible?
 
On keypress event

-----------------------------
If keycode = vbkeyreturn Then

Else

End If
-----------------------------

If vbkeyreturn doesnt work you have to find key ascii number, Rural guy told you where you can find it. If it is not there then capture it with error traping in VBA (put a watch in VBA on keypress event).

That is how i did it.
 
On keypress event

-----------------------------
If keycode = vbkeyreturn Then

Else

End If
-----------------------------
Luka,

Does this short sub say "do nothing" if the key pressed is coded with the constant "vbkeyreturn"?? Is that what you're trying to tell me here?
 
Yes

I dont know any other way how to disable the button. I did the same thing with ESC button and it works fine.
 
Adam - Try this:
Code:
Private Sub Text0_KeyPress(KeyAscii As Integer)
    If KeyAscii = 13 Then KeyAscii = 0
End Sub
 
Luka,

I have tried...

**KeyCode = 13
**KeyAscii = 13
**KeyCode = vbKeyReturn

with your IF, THEN (nothing here) code, and none of it works. I thought the data entry specification on the form would influence this, but it has no effect either. Are you leaving something out here, or is that simply all you have written in the sub?

Edit - Sorry Bob, was typing this when I got cut off...
 
Bob,

I have been writing the KeyPress on the form event. But, with yours, neither the form event or the control event works. Still entering a new record. :confused:
 
You could hook into the windows messaging and catch the message of sending the enter keystroke. This is a little out of my league but I think that would be the only option to total disable the enter keystroke in your db.
 
Keith,

Do you have any idea as to why I can't get this to work right!?
 
Adam,
Do you have the Form's KeyPreview property set to YES?
 
What are you actually trying to prevent the user from doing? Moving fields by pressing enter? Moving records by pressing enter? If you go into Tools=>Options you can change the behavior of the enter key.
 

Users who are viewing this thread

Back
Top Bottom