Running total to new in different field

  • Thread starter gjameson via AccessMonster.com
  • Start date
G

gjameson via AccessMonster.com

I have a database that I want to keep track of a number list for meters that
is unique.
Meters have to have a unique number assigned to them. We order these in
batches. What I am trying to do is carry over my Ending Meter Number field to
the new record field of Begin Meter Number. I have a formula to correctly
come up with the Ending Meter Number. I have tried several different
approaches, but nothing seems to work.

I have tried this :

Private Sub Form_BeforeInsert(Cancel As Integer)
Me.[Begin Meter Number] = Me.[End Meter Number]
End Sub

TIA,

Gerald
 
A

Al Campagna

G,
You should be able to create a Default Value for Begin Meter Number... assuming a
meter never "wraps" back to zero, and always increments positively, and MeterSerialNo is
Text...
= DMax("[End Meter Number]","tblMeterReadings", "[MeterSerialNo] = '" & MeterSerialNo
& "'")

(with spaces in quotes for clarity... remove when using)...
..."[MeterSerialNo] = ' " & MeterSerialNo & " ' "
Every New reading record will have a Default Value for the last (largest) [End Meter
Number] for that meter serial number.
--
hth
Al Campagna . Candia Computer Consulting . Candia, NH USA
Microsoft Access MVP
http://home.comcast.net/~cccsolutions

"Find a job that you love, and you'll never work a day in your life."
 
G

gjameson via AccessMonster.com

Hi Al,

Thanks for the response. I am a little confused as to where to put this code.
In the Begin Meter Number field or in the BeforeInsert event?

Gerald

Al said:
G,
You should be able to create a Default Value for Begin Meter Number... assuming a
meter never "wraps" back to zero, and always increments positively, and MeterSerialNo is
Text...
= DMax("[End Meter Number]","tblMeterReadings", "[MeterSerialNo] = '" & MeterSerialNo
& "'")

(with spaces in quotes for clarity... remove when using)...
..."[MeterSerialNo] = ' " & MeterSerialNo & " ' "
Every New reading record will have a Default Value for the last (largest) [End Meter
Number] for that meter serial number.
I have a database that I want to keep track of a number list for meters that
is unique.
[quoted text clipped - 13 lines]
 
A

Al Campagna

G,
It should be in the DefaultValue for Begin Meter Number.
--
hth
Al Campagna . Candia Computer Consulting . Candia, NH USA
Microsoft Access MVP
http://home.comcast.net/~cccsolutions

"Find a job that you love, and you'll never work a day in your life."

gjameson via AccessMonster.com said:
Hi Al,

Thanks for the response. I am a little confused as to where to put this code.
In the Begin Meter Number field or in the BeforeInsert event?

Gerald

Al said:
G,
You should be able to create a Default Value for Begin Meter Number... assuming a
meter never "wraps" back to zero, and always increments positively, and MeterSerialNo is
Text...
= DMax("[End Meter Number]","tblMeterReadings", "[MeterSerialNo] = '" &
MeterSerialNo
& "'")

(with spaces in quotes for clarity... remove when using)...
..."[MeterSerialNo] = ' " & MeterSerialNo & " ' "
Every New reading record will have a Default Value for the last (largest) [End Meter
Number] for that meter serial number.
I have a database that I want to keep track of a number list for meters that
is unique.
[quoted text clipped - 13 lines]
 

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