Using Hotkey to navigate to a new record in subform from sub-subform

franca

New member
Local time
Today, 00:13
Joined
Nov 4, 2011
Messages
3
I am trying to create a hotkey to navigate users from a sub-subform to the subform and enter a new record. I have tried using goto control and goto record, but both end up in errors. The problem is that Access says the subform is closed or the control i am identifying doesn't exist. Any thoughts on how to do this. I am trying to keep users from having to leave the keyboard and mouse to a new record in the subform. thanks for any suggestions.
 
You can't refer to the form object because in a subform it is an instance held inside another object.

Move the focus to the right level then:
DoCmd.GoToRecord , , acNewRec
 
Any chance you could provide a basic sample of how that would look? I don't play in the VBA that much at all. Would you make this an event for something like key press or something like that? I used to be able to do things like this by creating an autokey macro, but that doesn't work for the mainform, subform and sub-subform navigation when in the sub-subform. Hope this is making sense.

Again thank you for the help.
 
OK, so I have the following that works perfectly for the first If statement, but the second one errors out...Any sugestions?

Can you have multiple keycodes within the KeyPress Event?

Private Sub Form_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then ' ( 13 = "Ctrl + M" Key )
Forms![FRMProdMain]![FRMProdSubMaterial].Enabled = True
Forms![FRMProdMain]![FRMProdSubMaterial]![MaterialNumber].SetFocus
DoCmd.GoToRecord , , acNewRec
Else
If KeyAscii = 4 Then ' ( 4 = "Ctrl + D" Key )
Forms![FRMProdMain]![FRMProdSubMaterial].Enabled = True
Forms![FRMProdMain].Enabled = True
Forms![FRMProdMain]![Date].SetFocus
DoCmd.GoToRecord , , acNewRec
End If
End If
End Sub
 

Users who are viewing this thread

Back
Top Bottom