Hi there.
Is there a way to set my last entry in a field as it's Default Value for my next entry?
Hi there.
Is there a way to set my last entry in a field as it's Default Value for my next entry?
In a form yes you can, not in a table.
in the after update event of the control use something like
Me.Yourcontrol.DefaultValue = Me.Yourcontrol
DLookup Syntax and others http://access.mvps.org/access/general/gen0018.htm
Please use the star below the post to say thanks if we have helped !
↓↓ It's down here ↓↓
It's a form to enter data into a table. So here's my form:
'frmBooking': 'Date' (DateField, entry in 'tblBooking'), 'cboSupplier' (ComboBox with choice of suppliers from 'tblSupplier', entry in 'tblBooking'.'valSupplier'), 'Amount' (NumberField, entry in tblBooking), 'cboAccount' (ComboBox with choice of Accounts from 'tblAccount' entry in 'tblbooking'.'valAccount'), 'cboMachine' (ComboBox with choice of machines from 'tblMachine' synchronized with 'cboAccount', entry in 'tbl.booking'.'valMachine')
I hope this is understandable...
I have a lot of entries where date and supplier stay the same. I thought it would be really cool, if I only have to change date and supplier if I have to... I don't know if (and how) this is possible...
I tried the following:
Private Sub cboSupplier_AfterUpdate()
Me!ValSupplier.DefaultValue = Me!ValSupplier
End Sub
Private Sub Date_AfterUpdate()
Me!Date.DefaultValue = Str(CDbl(Me!Date))
End Sub
It doesn't work...
Last edited by STarDavos; 01-22-2022 at 03:08 AM. Reason: re-phrasing
Made the following change and now it works fine:
FROM:
Private Sub cboSupplier_AfterUpdate()
Me!ValSupplier.DefaultValue = Me!ValSupplier
End Sub
TO:
Private Sub cboSupplier_AfterUpdate()
Me!cboSupplier.DefaultValue = Me!cboSupplier
End Sub
Thanks for all your help!!!
I'll be back (...SOON...)
You really should be using Me. not Me!
There is a technical explanation for what ! is but I don't suppose you want to know that yet. The practical points would be that
a) dot (.) invokes intellisense - you'd get a list of properties, methods and controls on the form which filters as you type the code. Helps prevent errors.
b) whatever follows the bang (!) is only processed at run time, so an error can be raised. When you compile (you are compiling code, yes?) it is not checked.
The more we hear silence, the more we begin to think about our value in this universe.
Paraphrase of Professor Brian Cox.
Oh... Thanks Micron