G
Gazza
Firstly sorry for posting this twice i posted in the wrong section originally
and for the long post.
I have three forms for adding different items to three different tables and
I seem to need the same code to do similar things on the forms.
I was thinking of creating modules for the code that is the same so I don’t
have to write it on all three forms. The problem is I am not quite sure where
to start.
I have created a module called exitform and added the following code :
Public Sub exitform2()
Select Case KeyCode
Case vbKeyEscape
KeyCode = 0
DoCmd.Close
End Select
End Sub
I have then added the following code to the forms keydown event
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
Call exitform
End Sub
But nothing seems to happen apart from the tab at the top with the form name
flashes once, so obviously there is an error in my code somewhere but I
haven`t a clue where it could be as the module code works (I had the code in
the on keydown event originally but moved it to a module as many forms will
use this code so I hopefully save myself a lot of typing)
Any help would be much appreciated
Thanks
Gareth
and for the long post.
I have three forms for adding different items to three different tables and
I seem to need the same code to do similar things on the forms.
I was thinking of creating modules for the code that is the same so I don’t
have to write it on all three forms. The problem is I am not quite sure where
to start.
I have created a module called exitform and added the following code :
Public Sub exitform2()
Select Case KeyCode
Case vbKeyEscape
KeyCode = 0
DoCmd.Close
End Select
End Sub
I have then added the following code to the forms keydown event
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
Call exitform
End Sub
But nothing seems to happen apart from the tab at the top with the form name
flashes once, so obviously there is an error in my code somewhere but I
haven`t a clue where it could be as the module code works (I had the code in
the on keydown event originally but moved it to a module as many forms will
use this code so I hopefully save myself a lot of typing)
Any help would be much appreciated
Thanks
Gareth