Dlast / dlookup

mtagliaferri

Registered User.
Local time
Today, 15:57
Joined
Jul 16, 2006
Messages
550
Hi I have a further problem which I don't really know how to use the DLOOKUP or DLAST function!
I need to populate the field "A" in the "frm1" with te same previous value in the "tbl1"
So if I create a new record by opening the frm1 in the DB attrached once inserted the date it will autopopulate the "A" field with the value 1 wich is the last value from the previous record. this will go on untill for some reason I change for example the value "A" to 5, then all the following new records once inserted the date will show 5 in the field "A"
I know it is the DLOOKUP or DLAST function but I don't know I to put in i place, any suggestions?
thanks
 

Attachments

I'm not completely sure I understand the exact problem; you say you want your field A to auto-populate with same value as previous value in last record. But when you change the value (in current record or previous record?), the A get the changed value... Is that the problem?

Also are you aware that DLast function doesn't actually return last value- it returns a random value? DMax() upon the autonumber key to return you the last value would be more appropriate:

Code:
=DMax("MyFieldIWantToDisplay", "MyTable", "MyAutoNumberKeyFieldName")

HTH.
 
Basicaly it is to fill up the form quickly, so that the final user does not have to type the value unsless this changes, so for every new record it is the same value, when this value changes all te new records will have the last new value.
Do i need to place this code in the control source or the field on the form?
and would this wright the valu on the table or it will only show it on the frm?

Thanks again
 
I have actually placed the code and it shows me te last record, but it wont allow me to change itand it will not wright it permanently on the tbl1
I need to change this value and to place it permanently on tbl1 as then I have a query which will make calculation using this value!
Thanks
 
In that case, you just need to set the textbox's Default Value property.

If your textbox is named MyTextbox, then in its DefaultValue property it would be:

=[MyTextbox]
 
...it wont allow me to change it and it will not write it permanently on the tbl1

This indicates that you put the code in the textbox's Control Source. This prevents editing the textbox and prevents it from being written to the table. As Banana said, it belongs in the textbox's Default Value, instead.
 

Users who are viewing this thread

Back
Top Bottom