Short answer: You cannot. This is because Access does not give you the ability to trigger data events on tables. It must occur in an event driven class like a form.
Long answer:
Firstly, define for yourself what "last record entered" means, by some criteria that Access will understand. For example, if your table has an autonumber field called ID, you could say that the last record entered is the one with the Max([ID]). Now you have the record, you probably only want one of the fields since you are unlikely to want to cram an entire record into one fiel'd default value?
Now you learn the DMax function. For an autonumber field named ID in a table named "Table1", DMax("[ID]","Table1") will give you the value of the ID field for the last record added.
So although you cannot specify the default value in the table definition as you may wish, you could mak sure that on your data entry form, the default value of the Text Box that you have bound to the target field, has the DMAX expression entered. It's almost as good. The down side is that if another record is added to Table1 after your user opens your data entry form, the value will not update.
Yeah, there are some versions of doing such, for instance using the default value property of form controls, either on each control, or through looping them using relevant form events. Here are some faqs faq702-4852, faq702-5010 (section 6). Calling such in either the After Update or After Insert event of a form, would hopefully determine whether you've got the values from the last altered or the last added record as default for the new record (this version shouldn't be dependent on an incrementing surrogate key).
Add a field to your table DateChanged type date.
Add a textbox to your page with the control source DateChanged. Make this invisible. Name it txtDateChanged.
On the form afterupdate add something like txtDateChanged.Value = Now()
Everytime the form is changed the [DateChanged] is updated (bit clunky, but it is a small piece of code) ~ now simply sort the form on DateChanged (decending) to have everything shown in reverse last changed order.
Regards Paul
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.