Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

autopopulation of fields

Status
Not open for further replies.

siddahuja

Programmer
Jul 9, 2003
2
CA
I have made a database which records readings of date of entry of data, previous reading of motor , present reading of motor(meter readings). Now the data is enetered every month and the above mentioned three fields are in the same table. I would acess to autopopulate the previous reading of this months entry woth previous months' present reading...that is if previous months table record is:

Date of entry Present Reading Previous Reading

6/1/2003 4000 2000

so i want this months reading to be:

Date of entry Present Reading Previous reading

7/1/2003 (to be entered by clerk) 4000
(lets say 5000)
similarly next months reading would be

Date of entry Present Reading Previous reading

8/1/2003 (to be entered by clerk) 5000

i.e. this months' previous reading field gets populated by previous month's present reading field.

How do i do that?

 
Access control could be populated in the OnCurrent event by

If NewRecord

Dim rst as Recordset

Set rst = CurrentDB.OpenRecordset("SELECT TOP 1 PresentReading FROM YourTable ORDER BY DateOfEntry DESC")

rst.MoveFirst

YourControl=rst!PresentReading

rst.Close
Set rst=Nothing

End If

Craig

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top