I need code for Access to have a continuous form with default data for
a field be taken from the previous field.
This is for a date field, so what it needs to do is find the previous
date entered in that form, and set the default to the new record to
that date plus one.
(The reason I want it to simply set the default is that I want it to
be possible for the user to change this date. Not all dates should
exist, but to make things quickly, it's faster to have it default to
the previous date entered than to have to enter it every time.
I've found this code online, which is meant to do something similar to
this, but I don't know how to adapt it to make it work on my database
(changing it to make the default be previous + 1 should be trivial).
http://www.tek-tips.com/faqs.cfm?fid=4852
------------------------------------------
In summary, this is the code from that posting that I need to know how to adapt:
'For individual controls
Private Sub Form_AfterUpdate()
'Setup error handling
On Error GoTo Form_AfterUpdate_Err
'Carry the batch number forward
Me.Controls("controlname").DefaultValue = """" &
Me.Controls("controlname").Value & """"
Form_AfterUpdate_Exit:
Exit Sub
Form_AfterUpdate_Err:
'Alert the user that an error has occurred
Call ErrorHandler(Err.Number, Err.Description, "frmACCT.Form_AfterUpdate")
Resume Form_AfterUpdate_Exit
End Sub
---------------------------------------------------
Thanks,
Munir |