subform.SetFocus
This code is trying to setfocus on the subform container so the Docmd will function properly. You need to replace "subform" with the name of your subform container. On your main form select your subform container and look at the properties sheet. On the other tab the name of your subform container will be displayed.