Updating subform to new record not overwriting old record 
Author Message
 Updating subform to new record not overwriting old record

I have a field on the main form that when selected should add a new record
to the subform to reflect a history of the event.

My problem is that rather then adding a new record on the subform it
overwrites the existing record.

How can I force a new record?

The subform is updated from data on the main form.  The subform is used to
keep a history of the event.  Rather then having the user enter the data I
want this to happen automatically.

Here is the code for the event.  Can anyone help?

Lou

Private Sub Talk_Number_Exit(Cancel As Integer)
'If the speaker is incoming then the talk history date and talk number
'is automatically filled in with the data from PT Date and Talk Number

    If [Incoming/Outgoing] = "Incoming" Then
        frm_Talk_Date_History![Talk History] = [PT Date]
        frm_Talk_Date_History![Talk #] = [Talk Number]
    Else
    End If
End Sub



Tue, 04 Nov 2003 07:34:25 GMT  
 Updating subform to new record not overwriting old record
To do this, you need to move the focus of the subform to a new record.
Try this:

me.frm_Talk_Date_History.setfocus
DoCmd.GoToRecord , , acNewRec
with me.frm_Talk_Date_History.form
    ![Talk History] = [PT Date]
    ![Talk #] = [Talk Number]
end with

Another method is to use the subform's recordsetclone

with with me.frm_Talk_Date_History.form.recordsetclone
    .addnew
    ![Talk History] = [PT Date]
    ![Talk #] = [Talk Number]
    .update
end with

--

Sandra Daigle, Microsoft Access MVP


Quote:
> I have a field on the main form that when selected should add a new
record
> to the subform to reflect a history of the event.

> My problem is that rather then adding a new record on the subform it
> overwrites the existing record.

> How can I force a new record?

> The subform is updated from data on the main form.  The subform is
used to
> keep a history of the event.  Rather then having the user enter the
data I
> want this to happen automatically.

> Here is the code for the event.  Can anyone help?

> Lou

> Private Sub Talk_Number_Exit(Cancel As Integer)
> 'If the speaker is incoming then the talk history date and talk
number
> 'is automatically filled in with the data from PT Date and Talk
Number

>     If [Incoming/Outgoing] = "Incoming" Then
>         frm_Talk_Date_History![Talk History] = [PT Date]
>         frm_Talk_Date_History![Talk #] = [Talk Number]
>     Else
>     End If
> End Sub



Tue, 04 Nov 2003 22:31:30 GMT  
 Updating subform to new record not overwriting old record
Sandra,

Thank you.  This solved my problem.

I had tried the .addnew method but it seems I did not complete it with
.update.

Works great now,

Thanks for your help

Louis


Quote:
> To do this, you need to move the focus of the subform to a new record.
> Try this:

> me.frm_Talk_Date_History.setfocus
> DoCmd.GoToRecord , , acNewRec
> with me.frm_Talk_Date_History.form
>     ![Talk History] = [PT Date]
>     ![Talk #] = [Talk Number]
> end with

> Another method is to use the subform's recordsetclone

> with with me.frm_Talk_Date_History.form.recordsetclone
>     .addnew
>     ![Talk History] = [PT Date]
>     ![Talk #] = [Talk Number]
>     .update
> end with

> --

> Sandra Daigle, Microsoft Access MVP



> > I have a field on the main form that when selected should add a new
> record
> > to the subform to reflect a history of the event.

> > My problem is that rather then adding a new record on the subform it
> > overwrites the existing record.

> > How can I force a new record?

> > The subform is updated from data on the main form.  The subform is
> used to
> > keep a history of the event.  Rather then having the user enter the
> data I
> > want this to happen automatically.

> > Here is the code for the event.  Can anyone help?

> > Lou

> > Private Sub Talk_Number_Exit(Cancel As Integer)
> > 'If the speaker is incoming then the talk history date and talk
> number
> > 'is automatically filled in with the data from PT Date and Talk
> Number

> >     If [Incoming/Outgoing] = "Incoming" Then
> >         frm_Talk_Date_History![Talk History] = [PT Date]
> >         frm_Talk_Date_History![Talk #] = [Talk Number]
> >     Else
> >     End If
> > End Sub



Wed, 05 Nov 2003 23:03:10 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Add New Records (ie. not overwriting old records)

2. How to save an old record to a new table when record is updated

3. Overwrite values, not add new records

4. New record on change of old record

5. problem use old record to create new record

6. Add new record and read-only old records

7. problems with ms access call old record to save as new record

8. problem use old record to create new record

9. Flip between editable new record and read-only old records

10. When a new record becomes an old record?


 
Powered by phpBB® Forum Software © phpBB Group