Try setting the focus to a control on the SubForm first. It is a two step process. Me.SubFormControlName.SetFocus Me.SubFormControlName.FORM.ControlOnSubForm.SetFocus
Using your control names of course. Keep in mind that forms are displayed on other forms by means of a SubFormControl. This SubFormControl defaults to the same name as the form it displays but it is not a requirement and can have a different name that the form it displays.
StuJol wrote:
[Quoted Text] >i have a main form with several sub forms located in it, built in access 2003 > >on my main form is a cmd button which makes sub form 1 visible and hides all >the other sub forms. sub form 1 is connected to a table. > >on sub form 1 is a cmd button for inseting a new record. all works fine > >im trying to get the cmd button on the main form to insert a new record once >the form is visible. my code for cmd button is: > >Private Sub cmdMakeNewSupplierPayment_Click() >On Error GoTo Err_cmdMakeNewSupplierPayment_Click > >' If EmployeeID combo is NULL, exit sub. > > If IsNull(Combo12) Then Exit Sub > >' Display Employee Details and hide all other forms. > > Me.sbfrmSuppliersMainWindow.Visible = False > Me.sbfrmSuppliersPayments.Visible = True > Me.sbfrmSuppliersDetails.Visible = False > >' Add new record > > DoCmd.GoToRecord , "", acNewRec > >Exit_cmdMakeNewSupplierPayment_Click: >Exit Sub > >Err_cmdMakeNewSupplierPayment_Click: > > Select Case Err.Number > Case Else > MsgBox "Error 061-005/" & Err.Number & "! " & Err.Description & >".", , CurrentDb.Properties("AppTitle") > Resume Exit_cmdMakeNewSupplierPayment_Click > End Select > >End Sub > >the DoCmd.GoToRecord , "", acNewRec line only referes to the main form and >im having difficulties finding the right code for it to add new record to sub >forms. > >any help would be very much appreciated.
-- HTH - RuralGuy (RG for short) acXP WinXP Pro Please post back to this forum so all may benefit.
Message posted via http://www.accessmonster.com
|