Results 1 to 6 of 6
  1. #1
    STarDavos is offline Novice
    Windows 10 Office 365
    Join Date
    Jan 2022
    Location
    Davos, Switzerland
    Posts
    11

    Default Value

    Hi there.



    Is there a way to set my last entry in a field as it's Default Value for my next entry?

  2. #2
    Minty is offline VIP
    Windows 10 Office 365
    Join Date
    Sep 2017
    Location
    UK - Wiltshire
    Posts
    3,001
    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 ↓↓

  3. #3
    STarDavos is offline Novice
    Windows 10 Office 365
    Join Date
    Jan 2022
    Location
    Davos, Switzerland
    Posts
    11
    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

  4. #4
    STarDavos is offline Novice
    Windows 10 Office 365
    Join Date
    Jan 2022
    Location
    Davos, Switzerland
    Posts
    11
    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...)

  5. #5
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,737
    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.

  6. #6
    STarDavos is offline Novice
    Windows 10 Office 365
    Join Date
    Jan 2022
    Location
    Davos, Switzerland
    Posts
    11
    Oh... Thanks Micron

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Default value
    By UT227 in forum Forms
    Replies: 5
    Last Post: 06-26-2017, 11:01 AM
  2. Set a default on the fly
    By Thompyt in forum Programming
    Replies: 5
    Last Post: 03-25-2016, 11:41 AM
  3. Default Value
    By Njliven in forum Access
    Replies: 1
    Last Post: 10-10-2012, 12:48 PM
  4. Set default value
    By accessnewb in forum Programming
    Replies: 3
    Last Post: 08-17-2011, 06:24 PM
  5. Default value
    By Hatye in forum Access
    Replies: 1
    Last Post: 06-19-2011, 05:16 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums