New record when Enter key pressed

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I would like to have a new record open when the user presses the Enter key on
a particular form. What code would I need to accomplish this. Thanks in
advance. Matt
 
You want a new record to open everytime they press enter? Yikes. I bet you
get a bunch of records added by mistake.

I would highly discourage this.
 
It is only one user on one form. That user is the only user able to access
this form. This user is very capable of maintaining this data. Also, if the
user doesn't enter a value for the primary key, it won't except it as a new
record. This is basically a function that the user is accustomed to and this
particular user is the primary data entry person for this database.
 
I have the exact same issue where I need a certain series of code events to
take place anytime the enter key is pressed from any field on the screen. If
anyone's got the method I'd use to accomplish this, I'd appreciate it!
Emma
 
Emma
I ended up having to use a different key than then Enter key. I set my code
to execute when the user presses the tilde(Shift+back tick mark). If you are
interested in the code, let me know and I'll post it. Basically I did a case
statement checking the ASCII key value and if it equaled the tilde, then my
code ran.
 
Matt -

If you don't mind posting the code, that would be very helpful. Also, what
was the reason behind not being able to use the Enter key. It does have a
unique ASCII value, doesn't it?
Thanks!
Emma
 
Emma

I think I just decided that it might cause alot of problems, so I used a key
that I knew the user would never use. You can try it with the Enter key.
You can find the Enter ASCII key value online. Here is the code for my first
field and then I just called this module from the key_press module of each of
the other text fields. Let me know if you need more help. Good Luck.

Private Sub Tag_Number_KeyPress(KeyAscii As Integer)
Select Case KeyAscii
Case 126
Me.Dirty = False
DoCmd.GoToRecord , , acNewRec
End Select
End Sub
 
Thanks! That works great.
Emma

Emmweb said:
Matt -

If you don't mind posting the code, that would be very helpful. Also, what
was the reason behind not being able to use the Enter key. It does have a
unique ASCII value, doesn't it?
Thanks!
Emma
 
Back
Top