Lynn_AccessUser
Registered User.
- Local time
- Today, 09:00
- Joined
- Feb 4, 2003
- Messages
- 125
I have a form with a subform. I am trying to add a shortcut key to a button which is enabled or disabled depending on whether a checkbox is checked or not. I need to put the code on the subform as well because the focus is sometimes on a field on the subform.
The code works fine except for one problem. When the checkbox is check hitting Crtl + R opens up a form which it should. The problem is when the checkbox is not checked it is suppose to open up a message box stating "HOSPITALIZED IS NOT CHECKED". When the user hits OK on the message box, it puts an R in the field on the subform because that is where the cursor was at when the user hit Crtl + R.
Here is the code on the subform.
If intctrl And KeyCode = vbKeyR Then
If IsNull(Forms!frm_Summary!Hospitalized) Or Forms! frm_Summary!Hospitalized = "" Then
MsgBox "HOSPITALIZED IS NOT CHECKED"
ElseIf Forms!frm_Summary!Hospitalized = 0 Then
MsgBox "HOSPITALIZED IS NOT CHECKED"
Else
DoCmd.OpenForm "frm_SummaryHospital", , , stLinkCriteria
End If
End If
The code works fine except for one problem. When the checkbox is check hitting Crtl + R opens up a form which it should. The problem is when the checkbox is not checked it is suppose to open up a message box stating "HOSPITALIZED IS NOT CHECKED". When the user hits OK on the message box, it puts an R in the field on the subform because that is where the cursor was at when the user hit Crtl + R.
Here is the code on the subform.
If intctrl And KeyCode = vbKeyR Then
If IsNull(Forms!frm_Summary!Hospitalized) Or Forms! frm_Summary!Hospitalized = "" Then
MsgBox "HOSPITALIZED IS NOT CHECKED"
ElseIf Forms!frm_Summary!Hospitalized = 0 Then
MsgBox "HOSPITALIZED IS NOT CHECKED"
Else
DoCmd.OpenForm "frm_SummaryHospital", , , stLinkCriteria
End If
End If