Results 1 to 6 of 6
  1. #1
    Miik is offline Novice
    Windows 10 Office 365
    Join Date
    May 2020
    Posts
    2

    is it possible to set default value for the field that would adapt to the value of another field?

    Hi, I'm new here and, I'm also novice in MS Access.

    I'd like to know whether it is possible to set default value for a field that would change its value according to the value of another field.
    This is to say I've got two tables:
    in the first one there are an id of a deal (IDDeal) and the deal number (DealNumber) - DealNumber is specific to IDDeal
    in the second table there are more other information about these deals. Apart from many fields there are also IDDeal and Deal Number.


    I'd like to somehow set the value of DealNumber in a way that when I insert the value of IDDeal, the DealNumber will appear automatically.

    I suppose this is possible, but I have no idea how to do that.
    I tried to do this afterwards using Update Query, but it 'heals' only records already written and after every new record it is necessary to run this query again. I'd like to make it more automatically
    I'd be glad if you mind helping me.

  2. #2
    Mickjav is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Mar 2019
    Location
    Margate, Kent
    Posts
    123
    I do this in one of my account programs I have say a suppler who has a default account set as say Groceries so as soon as I select a supplier the general ledger account default is set

    I do it like Me.subform.Controls("AccountID").DefaultValue = Me![SupplierID]

  3. #3
    Miik is offline Novice
    Windows 10 Office 365
    Join Date
    May 2020
    Posts
    2
    Thanks for your response, maybe stupid question but where I should insert the code like 'Me.subform.Controls("AccountID").DefaultValue = Me![SupplierID]'? In Macro?

  4. #4
    Mickjav is offline Competent Performer
    Windows 10 Office 365
    Join Date
    Mar 2019
    Location
    Margate, Kent
    Posts
    123
    In the after update of a combobox but it does depend on how your system is setup.

    mick

  5. #5
    Gicu's Avatar
    Gicu is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,250
    Milk,

    You don't need the Deal Number in the second table, as there is a one-to-one relationship between the IDDeal and Deal Number and you can always get it by joining the two tables by IDDeal and bringing the Deal Number from the first table. Having it in both tables goes against the good db design (have a readon this here:https://www.justsoftwaresolutions.co...cate-data.html) and can cause data integrity problems.

    Cheers,
    Vlad Cucinschi
    MS Access Developer
    http://forestbyte.com/

  6. #6
    Mickjav is offline Competent Performer
    Windows 10 Office 365
    Join Date
    Mar 2019
    Location
    Margate, Kent
    Posts
    123
    Thanks @gicu missed that.

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

Similar Threads

  1. Replies: 1
    Last Post: 02-15-2018, 03:43 AM
  2. Dateadd as default in field
    By jmuirman1 in forum Access
    Replies: 1
    Last Post: 01-11-2018, 09:49 AM
  3. Default value of a field
    By data808 in forum Forms
    Replies: 4
    Last Post: 01-10-2014, 08:13 PM
  4. Default value in field based on value in other field
    By smith.jr in forum Database Design
    Replies: 2
    Last Post: 01-08-2014, 12:29 PM
  5. Default Value from Another Field
    By ineedaccesshelp in forum Access
    Replies: 5
    Last Post: 11-28-2012, 12:37 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