Can this be done

  • Thread starter Thread starter Thomas Simsion
  • Start date Start date
T

Thomas Simsion

I have a sub form. When I go to the next record I want Data from the
previous record to update a different record by use of a text box I.e Next
service date to update Service due on new record.
 
I have a sub form. When I go to the next record I want Data from the
previous record to update a different record by use of a text box I.e Next
service date to update Service due on new record.

You can, in the "next service date" control's "AfterUpdate" event procedure, set
the "Service Due" control's "Default Value" to the appropriate value.
 
I presume the appropriate Value is previous record next service date

It depends on what value your application finds "appropriate", but actually, at
that moment, it would *not* be the previous record, it would be the "current"
record. Is your "Service Due" just another date field? If so, what is the
significance of having 2 fields with the same data, or are these two fields in
different tables? I might be just a little confused here, so maybe you should
provide a little more information on what you are doing and what field/form
objects are involved.
 
Ok I have a subform which I use to generate the next service date by putting
the number of days to the next service date this creates a record in the
table Next service date So when I create the next record I wish this record
next service date to fill in on the next record service date I.E. Same table
but next record could you give me an example. Thanks for your help.
 
Ok I have a subform which I use to generate the next service date by putting
the number of days to the next service date this creates a record in the
table Next service date So when I create the next record I wish this record
next service date to fill in on the next record service date I.E. Same table
but next record could you give me an example. Thanks for your help.

Automatically generating records in this way can cause no end of grief. The
"next service date" can be calculated on the form in each existing record by
adding a textbox with it's "Control Source" property set to something like this:

=DateAdd("d", [NumberOfDays],[DateField])

Where "NumberOfDays" is the field that holds the number of days to next service
and "DateField" is the field that holds the data of the last service.
 
Yes I have done that already on the record how can I now get this to input
to the next record.
Bruce M. Thompson said:
Ok I have a subform which I use to generate the next service date by putting
the number of days to the next service date this creates a record in the
table Next service date So when I create the next record I wish this record
next service date to fill in on the next record service date I.E. Same table
but next record could you give me an example. Thanks for your help.

Automatically generating records in this way can cause no end of grief. The
"next service date" can be calculated on the form in each existing record by
adding a textbox with it's "Control Source" property set to something like this:

=DateAdd("d", [NumberOfDays],[DateField])

Where "NumberOfDays" is the field that holds the number of days to next service
and "DateField" is the field that holds the data of the last service.
 
Yes I have done that already on the record how can I now get this to input
to the next record.

You can add a command button to the form to set the default value of the "Next
Service Date" control to "Next Service Date" plus the value of "Days To Next
Service" as obtained from the current record:

'***
'Make sure record is saved
If Me.Dirty Then Me.Dirty = False

'Only set DefaultValue if there is a value in current record
If Len(Me![Next Service Date] & vbNullString) > 0 Then
Me.txtNextServiceDate.DefaultValue = _
DateAdd("d",Nz(Me![Days To Next Service], 0),Me![Next Service Date]
End If
'***

You need to replace "Next Service Date" with the date field on your form,
"txtNextServiceDate" with the name of the control to which you want to assign
the new date value and "Days To Next Service" with the name of the field in
which you store the "Days" to next service.

Is this what you are looking for?
 
Back
Top