Access noob, need help with OnKeyPress event for the TAB key

oZone

Registered User.
Local time
Today, 13:06
Joined
Oct 17, 2008
Messages
103
I have a home movies database and a form that allows the user to add actors (for assigning them to movies) by entering the star name into a text box. But without a pop up message, there's no visual confirmation that the data was written to the database.

I'd like to add an OnKeyPress event (or OnKeyDown or etc...) that pops up a message like "Data successfully added to database" when the user presses the TAB button. How would you do this?

I tried this just as a test and it worked great:
Code:
Private Sub Form_KeyPress(KeyAscii As Integer)
If KeyAscii = vbKeyEscape Then
MsgBox "ESC pressed."
End If
End Sub

then I tried substituting the word "Escape" with "Tab" but got errors...

Help?
 
Use the form's After Update event:

Code:
Msgbox "This Record has been saved", vbInformation, "Saved Record"
 
:D Perfect! Thank you very much sir! :D

This worked great! And a good idea to do it "after update"... I should've thought of that... ehh, the woes of being a noob... :o

For anyone else who stumbles across this same situation (for the TAB key), the following code did work for me:

Code:
Private Sub Form_KeyPress(KeyAscii As Integer)
If KeyAscii = vbKeyTab Then
MsgBox "Success! The record was added."
End If

Hey Bob? Has anyone told you "YOU ROCK!!!" lately? Well if not, YOU ROCK! :)
 
This works great, but after playing with it a little while I noticed something that needs fixing.

After adding a new star using the AddStars form, I close the form and return to the main form (MovieDetails) and look through the combo box menu and the newly added actor isn't listed.

I know the new actor is in the DB because if I open the Stars table, he/she is in it.

Is there a way to update the main form with the new data once a related table has been updated? (without requiring the user to close, then re-open the form just to see the newly added star)? :confused:
 
Last edited:
What you need in the AddStars form's After Update event, put

Forms!MovieDetails.YourComboBoxNameHere.Requery
 

Users who are viewing this thread

Back
Top Bottom