display an entry from a previous record

G

Guest

I track vehicle mileage on all our work vehicles. I have been creating
double entries by entering beginning and ending. How would I create a box to
display the ending mileage from the previous record?

Now my vehicles are sorted by numbers ... unit 12, 21, 22 etc. and how would
I want to create tables to track these? Currently I use one table to track
all vehicles.

Thanks Jen
 
B

butboris via AccessMonster.com

Hi jen,
If I understand you correctly, it sounds like your table structure needs some
work.
I think you need two tables, one for vehicles and one for milages, the
relationships would be one vehicle to many milages.
Make the milages a continuous sub-form and place this code into the "after-
update" event of the end milage text box on the form. Change the names to
whatever the names are that you are using.

Private Sub EndTextboxname_AfterUpdate()
Me.Begintextboxname.DefaultValue = """" & Me.EndTextboxname.Value & """"
End Sub

Hope this helps
 
B

butboris via AccessMonster.com

Hi jen,
If I understand you correctly, it sounds like your table structure needs some
work.
I think you need two tables, one for vehicles and one for milages, the
relationships would be one vehicle to many milages.
Make the milages a continuous sub-form and place this code into the "after-
update" event of the end milage text box on the form. Change the names to
whatever the names are that you are using.

Private Sub EndTextboxname_AfterUpdate()
Me.Begintextboxname.DefaultValue = """" & Me.EndTextboxname.Value & """"
End Sub

Hope this helps
 
B

butboris via AccessMonster.com

Hi jen,
If I understand you correctly, it sounds like your table structure needs some
work.
I think you need two tables, one for vehicles and one for milages, the
relationships would be one vehicle to many milages.
Make the milages a continuous sub-form and place this code into the "after-
update" event of the end milage text box on the form. Change the names to
whatever the names are that you are using.

Private Sub EndTextboxname_AfterUpdate()
Me.Begintextboxname.DefaultValue = """" & Me.EndTextboxname.Value & """"
End Sub

Hope this helps
 
B

butboris via AccessMonster.com

Appologies for the triple entry, my fault!!
Hi jen,
If I understand you correctly, it sounds like your table structure needs some
work.
I think you need two tables, one for vehicles and one for milages, the
relationships would be one vehicle to many milages.
Make the milages a continuous sub-form and place this code into the "after-
update" event of the end milage text box on the form. Change the names to
whatever the names are that you are using.

Private Sub EndTextboxname_AfterUpdate()
Me.Begintextboxname.DefaultValue = """" & Me.EndTextboxname.Value & """"
End Sub

Hope this helps
I track vehicle mileage on all our work vehicles. I have been creating
double entries by entering beginning and ending. How would I create a box to
[quoted text clipped - 5 lines]
Thanks Jen
 
G

Guest

I agree with the previous responder, but I do have an alternative to using a
subform to display the previous entries in the milage table. You could look
up the previous ending milagde for the vehiclde in the form's Current event
and put it in the beginning milage control on your form using the DMax
function:

Me.txtBeginMiles = Nz(DLookup("[EndMiles]", "MilageTable", "[VehicleID] = " _
& Me.txtVehicleID),0)

As to having a table for each vehicle - BBBBAAAADDDD IIIIDDDDEEEEAAAA!!!!
 
G

Guest

I have changed my tables to match what you typed renamed the fields and still
can not get this code to work. It highlights the following as an
error...........HELP

& Me.txtVehicleID),0)



Klatuu said:
I agree with the previous responder, but I do have an alternative to using a
subform to display the previous entries in the milage table. You could look
up the previous ending milagde for the vehiclde in the form's Current event
and put it in the beginning milage control on your form using the DMax
function:

Me.txtBeginMiles = Nz(DLookup("[EndMiles]", "MilageTable", "[VehicleID] = " _
& Me.txtVehicleID),0)

As to having a table for each vehicle - BBBBAAAADDDD IIIIDDDDEEEEAAAA!!!!

Jen said:
I track vehicle mileage on all our work vehicles. I have been creating
double entries by entering beginning and ending. How would I create a box to
display the ending mileage from the previous record?

Now my vehicles are sorted by numbers ... unit 12, 21, 22 etc. and how would
I want to create tables to track these? Currently I use one table to track
all vehicles.

Thanks Jen
 
G

Guest

This is all one line. The _ at the end of the first line is just a line
continuation code. If it fits on one line in your code window, remove it.

Me.txtBeginMiles = Nz(DLookup("[EndMiles]", "MilageTable", "[VehicleID] = " _
& Me.txtVehicleID),0)

Also, this code assumes [VehicleID] is a numeric field in Milage Table. If
it is a text field, you need to enclose Me.txtVehicleID in single quotes like
this:

Me.txtBeginMiles = Nz(DLookup("[EndMiles]", "MilageTable", "[VehicleID] = '" _
& Me.txtVehicleID) & "'",0)

Jen said:
I have changed my tables to match what you typed renamed the fields and still
can not get this code to work. It highlights the following as an
error...........HELP

& Me.txtVehicleID),0)



Klatuu said:
I agree with the previous responder, but I do have an alternative to using a
subform to display the previous entries in the milage table. You could look
up the previous ending milagde for the vehiclde in the form's Current event
and put it in the beginning milage control on your form using the DMax
function:

Me.txtBeginMiles = Nz(DLookup("[EndMiles]", "MilageTable", "[VehicleID] = " _
& Me.txtVehicleID),0)

As to having a table for each vehicle - BBBBAAAADDDD IIIIDDDDEEEEAAAA!!!!

Jen said:
I track vehicle mileage on all our work vehicles. I have been creating
double entries by entering beginning and ending. How would I create a box to
display the ending mileage from the previous record?

Now my vehicles are sorted by numbers ... unit 12, 21, 22 etc. and how would
I want to create tables to track these? Currently I use one table to track
all vehicles.

Thanks Jen
 
G

Guest

I double checked and they are listed as numerical but I have been entering
the code under Form AfterUpdate. Is this where I should list it?



Klatuu said:
This is all one line. The _ at the end of the first line is just a line
continuation code. If it fits on one line in your code window, remove it.

Me.txtBeginMiles = Nz(DLookup("[EndMiles]", "MilageTable", "[VehicleID] = " _
& Me.txtVehicleID),0)

Also, this code assumes [VehicleID] is a numeric field in Milage Table. If
it is a text field, you need to enclose Me.txtVehicleID in single quotes like
this:

Me.txtBeginMiles = Nz(DLookup("[EndMiles]", "MilageTable", "[VehicleID] = '" _
& Me.txtVehicleID) & "'",0)

Jen said:
I have changed my tables to match what you typed renamed the fields and still
can not get this code to work. It highlights the following as an
error...........HELP

& Me.txtVehicleID),0)



Klatuu said:
I agree with the previous responder, but I do have an alternative to using a
subform to display the previous entries in the milage table. You could look
up the previous ending milagde for the vehiclde in the form's Current event
and put it in the beginning milage control on your form using the DMax
function:

Me.txtBeginMiles = Nz(DLookup("[EndMiles]", "MilageTable", "[VehicleID] = " _
& Me.txtVehicleID),0)

As to having a table for each vehicle - BBBBAAAADDDD IIIIDDDDEEEEAAAA!!!!

:

I track vehicle mileage on all our work vehicles. I have been creating
double entries by entering beginning and ending. How would I create a box to
display the ending mileage from the previous record?

Now my vehicles are sorted by numbers ... unit 12, 21, 22 etc. and how would
I want to create tables to track these? Currently I use one table to track
all vehicles.

Thanks Jen
 
G

Guest

Actually, I think I gave bad advice, rather than the DLoookup, I think what
you need is DMax, which will return the highest value. The DLookup would
return the first record it finds, which would probably not be the correct
record.

I would suggest you put it in the Control Source property of txtBeginMiles
like this (Note it needs the actual form name here, Me. will not work in this
situation):

=DMax("[EndMiles]", "MilageTable", "[VehicleID] = " & Me.txtVehicleID),0)

Jen said:
I double checked and they are listed as numerical but I have been entering
the code under Form AfterUpdate. Is this where I should list it?



Klatuu said:
This is all one line. The _ at the end of the first line is just a line
continuation code. If it fits on one line in your code window, remove it.

Me.txtBeginMiles = Nz(DLookup("[EndMiles]", "MilageTable", "[VehicleID] = " _
& Me.txtVehicleID),0)

Also, this code assumes [VehicleID] is a numeric field in Milage Table. If
it is a text field, you need to enclose Me.txtVehicleID in single quotes like
this:

Me.txtBeginMiles = Nz(DLookup("[EndMiles]", "MilageTable", "[VehicleID] = '" _
& Me.txtVehicleID) & "'",0)

Jen said:
I have changed my tables to match what you typed renamed the fields and still
can not get this code to work. It highlights the following as an
error...........HELP

& Me.txtVehicleID),0)



:

I agree with the previous responder, but I do have an alternative to using a
subform to display the previous entries in the milage table. You could look
up the previous ending milagde for the vehiclde in the form's Current event
and put it in the beginning milage control on your form using the DMax
function:

Me.txtBeginMiles = Nz(DLookup("[EndMiles]", "MilageTable", "[VehicleID] = " _
& Me.txtVehicleID),0)

As to having a table for each vehicle - BBBBAAAADDDD IIIIDDDDEEEEAAAA!!!!

:

I track vehicle mileage on all our work vehicles. I have been creating
double entries by entering beginning and ending. How would I create a box to
display the ending mileage from the previous record?

Now my vehicles are sorted by numbers ... unit 12, 21, 22 etc. and how would
I want to create tables to track these? Currently I use one table to track
all vehicles.

Thanks Jen
 
G

Guest

Placed it just like this

=DMax("[EndMiles]", "MileageTable", "[VehicleID] = " &
FrmVehicle.txtVehicleID),0)

but now it gives me a syntac error and will not allow me to use this
expression


Klatuu said:
Actually, I think I gave bad advice, rather than the DLoookup, I think what
you need is DMax, which will return the highest value. The DLookup would
return the first record it finds, which would probably not be the correct
record.

I would suggest you put it in the Control Source property of txtBeginMiles
like this (Note it needs the actual form name here, Me. will not work in this
situation):

=DMax("[EndMiles]", "MilageTable", "[VehicleID] = " & Me.txtVehicleID),0)

Jen said:
I double checked and they are listed as numerical but I have been entering
the code under Form AfterUpdate. Is this where I should list it?



Klatuu said:
This is all one line. The _ at the end of the first line is just a line
continuation code. If it fits on one line in your code window, remove it.

Me.txtBeginMiles = Nz(DLookup("[EndMiles]", "MilageTable", "[VehicleID] = " _
& Me.txtVehicleID),0)

Also, this code assumes [VehicleID] is a numeric field in Milage Table. If
it is a text field, you need to enclose Me.txtVehicleID in single quotes like
this:

Me.txtBeginMiles = Nz(DLookup("[EndMiles]", "MilageTable", "[VehicleID] = '" _
& Me.txtVehicleID) & "'",0)

:

I have changed my tables to match what you typed renamed the fields and still
can not get this code to work. It highlights the following as an
error...........HELP

& Me.txtVehicleID),0)



:

I agree with the previous responder, but I do have an alternative to using a
subform to display the previous entries in the milage table. You could look
up the previous ending milagde for the vehiclde in the form's Current event
and put it in the beginning milage control on your form using the DMax
function:

Me.txtBeginMiles = Nz(DLookup("[EndMiles]", "MilageTable", "[VehicleID] = " _
& Me.txtVehicleID),0)

As to having a table for each vehicle - BBBBAAAADDDD IIIIDDDDEEEEAAAA!!!!

:

I track vehicle mileage on all our work vehicles. I have been creating
double entries by entering beginning and ending. How would I create a box to
display the ending mileage from the previous record?

Now my vehicles are sorted by numbers ... unit 12, 21, 22 etc. and how would
I want to create tables to track these? Currently I use one table to track
all vehicles.

Thanks Jen
 
G

Guest

Sorry, I did not check my syntax

=DMax("[EndMiles]", "MilageTable", "[VehicleID] = " &
[Forms]![FrmVehicle]![txtVehicleID]),0)

Jen said:
Placed it just like this

=DMax("[EndMiles]", "MileageTable", "[VehicleID] = " &
FrmVehicle.txtVehicleID),0)

but now it gives me a syntac error and will not allow me to use this
expression


Klatuu said:
Actually, I think I gave bad advice, rather than the DLoookup, I think what
you need is DMax, which will return the highest value. The DLookup would
return the first record it finds, which would probably not be the correct
record.

I would suggest you put it in the Control Source property of txtBeginMiles
like this (Note it needs the actual form name here, Me. will not work in this
situation):

=DMax("[EndMiles]", "MilageTable", "[VehicleID] = " & Me.txtVehicleID),0)

Jen said:
I double checked and they are listed as numerical but I have been entering
the code under Form AfterUpdate. Is this where I should list it?



:

This is all one line. The _ at the end of the first line is just a line
continuation code. If it fits on one line in your code window, remove it.

Me.txtBeginMiles = Nz(DLookup("[EndMiles]", "MilageTable", "[VehicleID] = " _
& Me.txtVehicleID),0)

Also, this code assumes [VehicleID] is a numeric field in Milage Table. If
it is a text field, you need to enclose Me.txtVehicleID in single quotes like
this:

Me.txtBeginMiles = Nz(DLookup("[EndMiles]", "MilageTable", "[VehicleID] = '" _
& Me.txtVehicleID) & "'",0)

:

I have changed my tables to match what you typed renamed the fields and still
can not get this code to work. It highlights the following as an
error...........HELP

& Me.txtVehicleID),0)



:

I agree with the previous responder, but I do have an alternative to using a
subform to display the previous entries in the milage table. You could look
up the previous ending milagde for the vehiclde in the form's Current event
and put it in the beginning milage control on your form using the DMax
function:

Me.txtBeginMiles = Nz(DLookup("[EndMiles]", "MilageTable", "[VehicleID] = " _
& Me.txtVehicleID),0)

As to having a table for each vehicle - BBBBAAAADDDD IIIIDDDDEEEEAAAA!!!!

:

I track vehicle mileage on all our work vehicles. I have been creating
double entries by entering beginning and ending. How would I create a box to
display the ending mileage from the previous record?

Now my vehicles are sorted by numbers ... unit 12, 21, 22 etc. and how would
I want to create tables to track these? Currently I use one table to track
all vehicles.

Thanks Jen
 
G

Guest

I give up it is still not working and I don't think it is going to...Thanks Jen

Klatuu said:
Sorry, I did not check my syntax

=DMax("[EndMiles]", "MilageTable", "[VehicleID] = " &
[Forms]![FrmVehicle]![txtVehicleID]),0)

Jen said:
Placed it just like this

=DMax("[EndMiles]", "MileageTable", "[VehicleID] = " &
FrmVehicle.txtVehicleID),0)

but now it gives me a syntac error and will not allow me to use this
expression


Klatuu said:
Actually, I think I gave bad advice, rather than the DLoookup, I think what
you need is DMax, which will return the highest value. The DLookup would
return the first record it finds, which would probably not be the correct
record.

I would suggest you put it in the Control Source property of txtBeginMiles
like this (Note it needs the actual form name here, Me. will not work in this
situation):

=DMax("[EndMiles]", "MilageTable", "[VehicleID] = " & Me.txtVehicleID),0)

:

I double checked and they are listed as numerical but I have been entering
the code under Form AfterUpdate. Is this where I should list it?



:

This is all one line. The _ at the end of the first line is just a line
continuation code. If it fits on one line in your code window, remove it.

Me.txtBeginMiles = Nz(DLookup("[EndMiles]", "MilageTable", "[VehicleID] = " _
& Me.txtVehicleID),0)

Also, this code assumes [VehicleID] is a numeric field in Milage Table. If
it is a text field, you need to enclose Me.txtVehicleID in single quotes like
this:

Me.txtBeginMiles = Nz(DLookup("[EndMiles]", "MilageTable", "[VehicleID] = '" _
& Me.txtVehicleID) & "'",0)

:

I have changed my tables to match what you typed renamed the fields and still
can not get this code to work. It highlights the following as an
error...........HELP

& Me.txtVehicleID),0)



:

I agree with the previous responder, but I do have an alternative to using a
subform to display the previous entries in the milage table. You could look
up the previous ending milagde for the vehiclde in the form's Current event
and put it in the beginning milage control on your form using the DMax
function:

Me.txtBeginMiles = Nz(DLookup("[EndMiles]", "MilageTable", "[VehicleID] = " _
& Me.txtVehicleID),0)

As to having a table for each vehicle - BBBBAAAADDDD IIIIDDDDEEEEAAAA!!!!

:

I track vehicle mileage on all our work vehicles. I have been creating
double entries by entering beginning and ending. How would I create a box to
display the ending mileage from the previous record?

Now my vehicles are sorted by numbers ... unit 12, 21, 22 etc. and how would
I want to create tables to track these? Currently I use one table to track
all vehicles.

Thanks Jen
 
G

Guest

It will work. It is a technique I use frequently. I don't know what problem
you are having.

Jen said:
I give up it is still not working and I don't think it is going to...Thanks Jen

Klatuu said:
Sorry, I did not check my syntax

=DMax("[EndMiles]", "MilageTable", "[VehicleID] = " &
[Forms]![FrmVehicle]![txtVehicleID]),0)

Jen said:
Placed it just like this

=DMax("[EndMiles]", "MileageTable", "[VehicleID] = " &
FrmVehicle.txtVehicleID),0)

but now it gives me a syntac error and will not allow me to use this
expression


:

Actually, I think I gave bad advice, rather than the DLoookup, I think what
you need is DMax, which will return the highest value. The DLookup would
return the first record it finds, which would probably not be the correct
record.

I would suggest you put it in the Control Source property of txtBeginMiles
like this (Note it needs the actual form name here, Me. will not work in this
situation):

=DMax("[EndMiles]", "MilageTable", "[VehicleID] = " & Me.txtVehicleID),0)

:

I double checked and they are listed as numerical but I have been entering
the code under Form AfterUpdate. Is this where I should list it?



:

This is all one line. The _ at the end of the first line is just a line
continuation code. If it fits on one line in your code window, remove it.

Me.txtBeginMiles = Nz(DLookup("[EndMiles]", "MilageTable", "[VehicleID] = " _
& Me.txtVehicleID),0)

Also, this code assumes [VehicleID] is a numeric field in Milage Table. If
it is a text field, you need to enclose Me.txtVehicleID in single quotes like
this:

Me.txtBeginMiles = Nz(DLookup("[EndMiles]", "MilageTable", "[VehicleID] = '" _
& Me.txtVehicleID) & "'",0)

:

I have changed my tables to match what you typed renamed the fields and still
can not get this code to work. It highlights the following as an
error...........HELP

& Me.txtVehicleID),0)



:

I agree with the previous responder, but I do have an alternative to using a
subform to display the previous entries in the milage table. You could look
up the previous ending milagde for the vehiclde in the form's Current event
and put it in the beginning milage control on your form using the DMax
function:

Me.txtBeginMiles = Nz(DLookup("[EndMiles]", "MilageTable", "[VehicleID] = " _
& Me.txtVehicleID),0)

As to having a table for each vehicle - BBBBAAAADDDD IIIIDDDDEEEEAAAA!!!!

:

I track vehicle mileage on all our work vehicles. I have been creating
double entries by entering beginning and ending. How would I create a box to
display the ending mileage from the previous record?

Now my vehicles are sorted by numbers ... unit 12, 21, 22 etc. and how would
I want to create tables to track these? Currently I use one table to track
all vehicles.

Thanks Jen
 
G

Guest

Is there any way you could look at the two tables and one form. I will be
send from my police email.

Klatuu said:
It will work. It is a technique I use frequently. I don't know what problem
you are having.

Jen said:
I give up it is still not working and I don't think it is going to...Thanks Jen

Klatuu said:
Sorry, I did not check my syntax

=DMax("[EndMiles]", "MilageTable", "[VehicleID] = " &
[Forms]![FrmVehicle]![txtVehicleID]),0)

:

Placed it just like this

=DMax("[EndMiles]", "MileageTable", "[VehicleID] = " &
FrmVehicle.txtVehicleID),0)

but now it gives me a syntac error and will not allow me to use this
expression


:

Actually, I think I gave bad advice, rather than the DLoookup, I think what
you need is DMax, which will return the highest value. The DLookup would
return the first record it finds, which would probably not be the correct
record.

I would suggest you put it in the Control Source property of txtBeginMiles
like this (Note it needs the actual form name here, Me. will not work in this
situation):

=DMax("[EndMiles]", "MilageTable", "[VehicleID] = " & Me.txtVehicleID),0)

:

I double checked and they are listed as numerical but I have been entering
the code under Form AfterUpdate. Is this where I should list it?



:

This is all one line. The _ at the end of the first line is just a line
continuation code. If it fits on one line in your code window, remove it.

Me.txtBeginMiles = Nz(DLookup("[EndMiles]", "MilageTable", "[VehicleID] = " _
& Me.txtVehicleID),0)

Also, this code assumes [VehicleID] is a numeric field in Milage Table. If
it is a text field, you need to enclose Me.txtVehicleID in single quotes like
this:

Me.txtBeginMiles = Nz(DLookup("[EndMiles]", "MilageTable", "[VehicleID] = '" _
& Me.txtVehicleID) & "'",0)

:

I have changed my tables to match what you typed renamed the fields and still
can not get this code to work. It highlights the following as an
error...........HELP

& Me.txtVehicleID),0)



:

I agree with the previous responder, but I do have an alternative to using a
subform to display the previous entries in the milage table. You could look
up the previous ending milagde for the vehiclde in the form's Current event
and put it in the beginning milage control on your form using the DMax
function:

Me.txtBeginMiles = Nz(DLookup("[EndMiles]", "MilageTable", "[VehicleID] = " _
& Me.txtVehicleID),0)

As to having a table for each vehicle - BBBBAAAADDDD IIIIDDDDEEEEAAAA!!!!

:

I track vehicle mileage on all our work vehicles. I have been creating
double entries by entering beginning and ending. How would I create a box to
display the ending mileage from the previous record?

Now my vehicles are sorted by numbers ... unit 12, 21, 22 etc. and how would
I want to create tables to track these? Currently I use one table to track
all vehicles.

Thanks Jen
 
G

Guest

Because of security issues, I can't receive it here at work. If you will
send it to my home, I can look at it over the week end. Hopefully, you can
decipher my address from this. Have to be careful of SPAM, you know.

dahargis Attack verizon diddlydot tennisNet
-tack
-diddly
-tennis

Jen said:
Is there any way you could look at the two tables and one form. I will be
send from my police email.

Klatuu said:
It will work. It is a technique I use frequently. I don't know what problem
you are having.

Jen said:
I give up it is still not working and I don't think it is going to...Thanks Jen

:

Sorry, I did not check my syntax

=DMax("[EndMiles]", "MilageTable", "[VehicleID] = " &
[Forms]![FrmVehicle]![txtVehicleID]),0)

:

Placed it just like this

=DMax("[EndMiles]", "MileageTable", "[VehicleID] = " &
FrmVehicle.txtVehicleID),0)

but now it gives me a syntac error and will not allow me to use this
expression


:

Actually, I think I gave bad advice, rather than the DLoookup, I think what
you need is DMax, which will return the highest value. The DLookup would
return the first record it finds, which would probably not be the correct
record.

I would suggest you put it in the Control Source property of txtBeginMiles
like this (Note it needs the actual form name here, Me. will not work in this
situation):

=DMax("[EndMiles]", "MilageTable", "[VehicleID] = " & Me.txtVehicleID),0)

:

I double checked and they are listed as numerical but I have been entering
the code under Form AfterUpdate. Is this where I should list it?



:

This is all one line. The _ at the end of the first line is just a line
continuation code. If it fits on one line in your code window, remove it.

Me.txtBeginMiles = Nz(DLookup("[EndMiles]", "MilageTable", "[VehicleID] = " _
& Me.txtVehicleID),0)

Also, this code assumes [VehicleID] is a numeric field in Milage Table. If
it is a text field, you need to enclose Me.txtVehicleID in single quotes like
this:

Me.txtBeginMiles = Nz(DLookup("[EndMiles]", "MilageTable", "[VehicleID] = '" _
& Me.txtVehicleID) & "'",0)

:

I have changed my tables to match what you typed renamed the fields and still
can not get this code to work. It highlights the following as an
error...........HELP

& Me.txtVehicleID),0)



:

I agree with the previous responder, but I do have an alternative to using a
subform to display the previous entries in the milage table. You could look
up the previous ending milagde for the vehiclde in the form's Current event
and put it in the beginning milage control on your form using the DMax
function:

Me.txtBeginMiles = Nz(DLookup("[EndMiles]", "MilageTable", "[VehicleID] = " _
& Me.txtVehicleID),0)

As to having a table for each vehicle - BBBBAAAADDDD IIIIDDDDEEEEAAAA!!!!

:

I track vehicle mileage on all our work vehicles. I have been creating
double entries by entering beginning and ending. How would I create a box to
display the ending mileage from the previous record?

Now my vehicles are sorted by numbers ... unit 12, 21, 22 etc. and how would
I want to create tables to track these? Currently I use one table to track
all vehicles.

Thanks Jen
 
G

Guest

Not a clue here is mine......

jpraterat
porofgalvestondot
com



Klatuu said:
Because of security issues, I can't receive it here at work. If you will
send it to my home, I can look at it over the week end. Hopefully, you can
decipher my address from this. Have to be careful of SPAM, you know.

dahargis Attack verizon diddlydot tennisNet
-tack
-diddly
-tennis

Jen said:
Is there any way you could look at the two tables and one form. I will be
send from my police email.

Klatuu said:
It will work. It is a technique I use frequently. I don't know what problem
you are having.

:

I give up it is still not working and I don't think it is going to...Thanks Jen

:

Sorry, I did not check my syntax

=DMax("[EndMiles]", "MilageTable", "[VehicleID] = " &
[Forms]![FrmVehicle]![txtVehicleID]),0)

:

Placed it just like this

=DMax("[EndMiles]", "MileageTable", "[VehicleID] = " &
FrmVehicle.txtVehicleID),0)

but now it gives me a syntac error and will not allow me to use this
expression


:

Actually, I think I gave bad advice, rather than the DLoookup, I think what
you need is DMax, which will return the highest value. The DLookup would
return the first record it finds, which would probably not be the correct
record.

I would suggest you put it in the Control Source property of txtBeginMiles
like this (Note it needs the actual form name here, Me. will not work in this
situation):

=DMax("[EndMiles]", "MilageTable", "[VehicleID] = " & Me.txtVehicleID),0)

:

I double checked and they are listed as numerical but I have been entering
the code under Form AfterUpdate. Is this where I should list it?



:

This is all one line. The _ at the end of the first line is just a line
continuation code. If it fits on one line in your code window, remove it.

Me.txtBeginMiles = Nz(DLookup("[EndMiles]", "MilageTable", "[VehicleID] = " _
& Me.txtVehicleID),0)

Also, this code assumes [VehicleID] is a numeric field in Milage Table. If
it is a text field, you need to enclose Me.txtVehicleID in single quotes like
this:

Me.txtBeginMiles = Nz(DLookup("[EndMiles]", "MilageTable", "[VehicleID] = '" _
& Me.txtVehicleID) & "'",0)

:

I have changed my tables to match what you typed renamed the fields and still
can not get this code to work. It highlights the following as an
error...........HELP

& Me.txtVehicleID),0)



:

I agree with the previous responder, but I do have an alternative to using a
subform to display the previous entries in the milage table. You could look
up the previous ending milagde for the vehiclde in the form's Current event
and put it in the beginning milage control on your form using the DMax
function:

Me.txtBeginMiles = Nz(DLookup("[EndMiles]", "MilageTable", "[VehicleID] = " _
& Me.txtVehicleID),0)

As to having a table for each vehicle - BBBBAAAADDDD IIIIDDDDEEEEAAAA!!!!

:

I track vehicle mileage on all our work vehicles. I have been creating
double entries by entering beginning and ending. How would I create a box to
display the ending mileage from the previous record?

Now my vehicles are sorted by numbers ... unit 12, 21, 22 etc. and how would
I want to create tables to track these? Currently I use one table to track
all vehicles.

Thanks Jen
 
G

Guest

Correction forgot the t

&jprateratportofgalvestondotcom&

Jen said:
Not a clue here is mine......
Klatuu said:
Because of security issues, I can't receive it here at work. If you will
send it to my home, I can look at it over the week end. Hopefully, you can
decipher my address from this. Have to be careful of SPAM, you know.

dahargis Attack verizon diddlydot tennisNet
-tack
-diddly
-tennis

Jen said:
Is there any way you could look at the two tables and one form. I will be
send from my police email.

:

It will work. It is a technique I use frequently. I don't know what problem
you are having.

:

I give up it is still not working and I don't think it is going to...Thanks Jen

:

Sorry, I did not check my syntax

=DMax("[EndMiles]", "MilageTable", "[VehicleID] = " &
[Forms]![FrmVehicle]![txtVehicleID]),0)

:

Placed it just like this

=DMax("[EndMiles]", "MileageTable", "[VehicleID] = " &
FrmVehicle.txtVehicleID),0)

but now it gives me a syntac error and will not allow me to use this
expression


:

Actually, I think I gave bad advice, rather than the DLoookup, I think what
you need is DMax, which will return the highest value. The DLookup would
return the first record it finds, which would probably not be the correct
record.

I would suggest you put it in the Control Source property of txtBeginMiles
like this (Note it needs the actual form name here, Me. will not work in this
situation):

=DMax("[EndMiles]", "MilageTable", "[VehicleID] = " & Me.txtVehicleID),0)

:

I double checked and they are listed as numerical but I have been entering
the code under Form AfterUpdate. Is this where I should list it?



:

This is all one line. The _ at the end of the first line is just a line
continuation code. If it fits on one line in your code window, remove it.

Me.txtBeginMiles = Nz(DLookup("[EndMiles]", "MilageTable", "[VehicleID] = " _
& Me.txtVehicleID),0)

Also, this code assumes [VehicleID] is a numeric field in Milage Table. If
it is a text field, you need to enclose Me.txtVehicleID in single quotes like
this:

Me.txtBeginMiles = Nz(DLookup("[EndMiles]", "MilageTable", "[VehicleID] = '" _
& Me.txtVehicleID) & "'",0)

:

I have changed my tables to match what you typed renamed the fields and still
can not get this code to work. It highlights the following as an
error...........HELP

& Me.txtVehicleID),0)



:

I agree with the previous responder, but I do have an alternative to using a
subform to display the previous entries in the milage table. You could look
up the previous ending milagde for the vehiclde in the form's Current event
and put it in the beginning milage control on your form using the DMax
function:

Me.txtBeginMiles = Nz(DLookup("[EndMiles]", "MilageTable", "[VehicleID] = " _
& Me.txtVehicleID),0)

As to having a table for each vehicle - BBBBAAAADDDD IIIIDDDDEEEEAAAA!!!!

:

I track vehicle mileage on all our work vehicles. I have been creating
double entries by entering beginning and ending. How would I create a box to
display the ending mileage from the previous record?

Now my vehicles are sorted by numbers ... unit 12, 21, 22 etc. and how would
I want to create tables to track these? Currently I use one table to track
all vehicles.

Thanks Jen
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top