Group:  Microsoft Access ยป microsoft.public.access.forms
Thread: new record in subform

DotNetBag
.NET Development Newsgroups

HTVi
TV Discussion Newsgroups

Our Hot Pick: Rising Antivirus 2006 - Certified by TUV & Checkmark! Get 10% discount by entering this coupon code: ONDISCOUNT10
Rising Antivirus 2006

new record in subform
StuJol 30.09.2006 12:47:01
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.
Re: new record in subform
"ruralguy via AccessMonster.com" <u12102[ at ]uwe> 30.09.2006 14:45:52
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

Home | Search | Terms | Imprint | Contact
Newsgroups Reader - provided by WiredBox.Net