Parent Set Focus problem and subform table update

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi
If have a parenet form with a subform.

When I enter data into the subform I need it to add the data into the table
but I am not sure how to do this.

Do I use a docmd to create a new record and if so how do I get the button to
add the data entered into fields which are unbound but does refer to the
table I need to update into.

Thanks
Noemi
 
Noemi said:
If have a parenet form with a subform.

When I enter data into the subform I need
it to add the data into the table but I am not
sure how to do this.

Without some description beyond "form with a subform" as to what you have,
how your data is organized, etc., it may be a little difficult for us to be
sure, either.
Do I use a docmd to create a new record and
if so how do I get the button to add the data
entered into fields which are unbound but does
refer to the table I need to update into.

What does "fields which are unbound but does refer to the table I need to
update into" mean? When you are handling data, it is almost always
preferrable to use bound Forms and Controls.

If you can clarify details and what you mean, perhaps someone will be able
to offer a useful suggestion.

Larry Linson
Microsoft Access MVP
 
Hi
Sorry about that

I have 1 form which is linked to tbl_StoreLicences while the subform is
linked to tbl_Licences.

What happens is the main form has text boxes which we enter data into and
once completed we click on a command button (located in the header of
mainform) which then sets the focus onto the subform and at the same time
updates the tbl_StoreLicences.

What happens then is we need to populate the text boxes on the subform and
once complete we need to click on the command button (located in the header
of Subform) which should then update the tbl_Licences and also set the focus
back to the main form and hide the subform.

the second is where I am having problems as it doesn't work.

Below is the code:

Main form:-

Public Sub cdmAdd_Click()
On Error GoTo Err_cdmAdd_Click

dbID = ID
Form_frm_Update2nd.Visible = True
Form_frm_Update2nd.ID = dbID
Forms!frm_Update1st!frm_Update2nd.SetFocus
Forms!frm_Update1st!frm_Update2nd.Form!ExpiryDate.SetFocus

Exit_cdmAdd_Click:
Exit Sub

Err_cdmAdd_Click:
MsgBox Err.Description
Resume Exit_cdmAdd_Click

End Sub

Private Sub Form_Load()
Form_frm_Update2nd.Visible = False
DoCmd.GoToRecord , , acNewRec
End Sub


Subform :-

Private Sub cmdAddDetails_Click()
On Error GoTo Err_cmdAddDetails_Click

Me.Requery
Me.Parent.SetFocus
Me.Parent.Store.SetFocus
Me.Parent.Form_frm_Update2nd.Visible = False

Exit_cmdAddDetails_Click:
Exit Sub

Err_cmdAddDetails_Click:
MsgBox Err.Description
Resume Exit_cmdAddDetails_Click

End Sub

Private Sub Form_Load()
DoCmd.GoToRecord , , acNewRec
End Sub

Thanks
Noemi
 
Back
Top