Here is what I have now in the AfterUpdate event of the Ending Mileage
field.
Private Sub Ending_Mileage_AfterUpdate()
Me![Beginning Mileage].DefaultValue = Chr$(34) & Me![Ending Mileage] &
Chr$(34)
End Sub
It appears the code is accurate because it's not red anymore but the
result
is the same, nothing happens when I select a new record to add.
Am I correct in saying what should happen with this code is when I select
a
new record for the next month on a vehicle, the Beginning Mileage will
automatically populate with the most recent ending mileage entered? This
is the way I hoped it would work. Sorry for the trouble!
--
Todd
Douglas J. Steele said:
Ending_Mileage indicates that the field name on your form is
Ending_Mileage
with an underline and no space between the words.
No, it doesn't necessarily mean that. If the field is named Ending
Mileage
(with a space), the procedure generated for the field will be:
Private Sub Ending_Mileage_AfterUpdate()
(Try it and see)
--
Doug Steele, Microsoft Access MVP
(no private e-mails, please)
Ending_Mileage indicates that the field name on your form is
Ending_Mileage
with an underline and no space between the words. Open
your form in design view and select the Beginning Mileage field. Open
properties and go to the Other tab. Is the name of this field
Beginning_Mileage? Also, Doug is right about the quotes. Your line of
code
should be:
Me!Beginning_Mileage.DefaultValue = Chr$(34) & Me!Ending_Mileage &
Chr$(34)
PC Datasheet
Providing Customers A Resource For Help With Access, Excel And Word
Applications
(e-mail address removed)
I tried the code you mentioned and nothing happened. Below is what I
entered
in the AfterUpdate event within the Ending Mileage field of the
subform:
Private Sub Ending_Mileage_AfterUpdate()
Me!Beginning Mileage.DefaultValue = Me!Ending Mileage
End Sub
The middle line of this code stayed red. I took the space out
between
both
beginning mileage and ending mileage and the line went back to normal
black
but the code still didn't work. I checked the table where the
fields
are
stored and the two mileage fields are spelled exactly as in the above
code.
Any suggestions?
--
Todd
:
Assuming the beginning mileage field on your form is named
BeginningMileage
and the ending mileage field is named EndingMileage, put the
following
code
in the AfterUpdate event of the ending mileage field:
Me!BeginningMileage.DefaultValue = Me!EndingMileage
PC Datasheet
Providing Customers A Resource For Help With Access, Excel And Word
Applications
(e-mail address removed)
My dbase has a form with a subform. In the subform you enter the
beginning
mileage and ending mileage of a vehicle every month (along with
other
things). How can I make it to where when I choose to add a new
record
(the
next month's data for a vehicle) that the ending mileage from the
previous
month is automatically inserted into the new records beginning
mileage
field
for the current month?