G
Guest
I have an application that evaluates the results of nutrition classes given
to needy people of all ages on how to prepare nutritious meals from the food
received from Harvesters. There are three option groups, three text boxes
and a check box for permission to use their name.
In an effort to insist on accurate data, the user is supposed to click on an
"Add Record" button which uses the Click event procedure and VBA to check the
accuracy of entries. I have added the following code to the Form keypress
event to try to prevent the enter key from being functional at all:
Private Sub Form_KeyPress(KeyAscii As Integer)
On Error GoTo Err_Form_KeyPress
If KeyAscii = vbKeyReturn Then
KeyAscii = 0
End If
Exit_Form_KeyPress:
Exit Sub
Err_Form_KeyPress:
MsgBox "Error: " & Err.Description & " (" & Err.Number & ")"
Resume Exit_Form_KeyPress
End Sub
This seems to work as long as the tab stop is less than the last piece of
data. However, once all entries have been completed, pressing the enter key
creates the record but does not necessarily process the edits in the Add
Record button Click event.
Why does the code seem to work part of the time? I think it is because the
tab function progressively moves execution from one tab stop to next each
time the enter key is pressed as it does in Windows. When it arrives at the
"Add Record" button, it executes the code beneith and progresses to the next
tab stop. This does not seem to stop it from occasionally creating an
inaccurate or blank record. Any ideas would be appreciated on how to stop
the enter key from functioning at all on this form.
EarlCPhillips
Ex-Mainframer Learning Access To Help Feed
the Hungry Through Harvesters Food Bank
to needy people of all ages on how to prepare nutritious meals from the food
received from Harvesters. There are three option groups, three text boxes
and a check box for permission to use their name.
In an effort to insist on accurate data, the user is supposed to click on an
"Add Record" button which uses the Click event procedure and VBA to check the
accuracy of entries. I have added the following code to the Form keypress
event to try to prevent the enter key from being functional at all:
Private Sub Form_KeyPress(KeyAscii As Integer)
On Error GoTo Err_Form_KeyPress
If KeyAscii = vbKeyReturn Then
KeyAscii = 0
End If
Exit_Form_KeyPress:
Exit Sub
Err_Form_KeyPress:
MsgBox "Error: " & Err.Description & " (" & Err.Number & ")"
Resume Exit_Form_KeyPress
End Sub
This seems to work as long as the tab stop is less than the last piece of
data. However, once all entries have been completed, pressing the enter key
creates the record but does not necessarily process the edits in the Add
Record button Click event.
Why does the code seem to work part of the time? I think it is because the
tab function progressively moves execution from one tab stop to next each
time the enter key is pressed as it does in Windows. When it arrives at the
"Add Record" button, it executes the code beneith and progresses to the next
tab stop. This does not seem to stop it from occasionally creating an
inaccurate or blank record. Any ideas would be appreciated on how to stop
the enter key from functioning at all on this form.
EarlCPhillips
Ex-Mainframer Learning Access To Help Feed
the Hungry Through Harvesters Food Bank