Consulting

Results 1 to 5 of 5

Thread: Access 2010 .adp FetchDefaults property not working as expected

  1. #1
    VBAX Mentor Movian's Avatar
    Joined
    Aug 2008
    Location
    NC, USA
    Posts
    399

    Access 2010 .adp FetchDefaults property not working as expected

    Have an access 2010 .adp project connect to SQL Express 2014

    I am in the process from moving user defineable default values from a table and using a custom solution for their entry to using the defaults in the fields within the SQL database.

    The problem I am running into is that when I create a new record then go to a subform with a default value, that subform doesn't technicaly have a record for this patient yet and as such it appears that access is not showing the default. Once I make a selection in any other field the default appears as the record has now been created and saved in the SQL database.....

    What can I do to ensure that the record is created on opening (I used to have a function that did this but has been removed due to primary key violation issues), OR simply get the system to show the default even if there is no record yet.
    "From the ashes of disaster grow the roses of success" - Chitty chitty bang bang

    "I fear not the man who has 10,000 kicks practiced once. I fear the man who has 1 kick practiced 10,000 times" - Bruce Lee

  2. #2
    VBAX Guru
    Joined
    Mar 2005
    Posts
    3,296
    Location
    Can you use a work around, If you update a field in VBA does that generate the defaults in the sub form without a key violation?

  3. #3
    VBAX Expert
    Joined
    Oct 2012
    Posts
    726
    Location
    Controls have a defaultvalue property.
    Field1.DefaultValue = "='foo'"

  4. #4
    VBAX Mentor Movian's Avatar
    Joined
    Aug 2008
    Location
    NC, USA
    Posts
    399
    OBP ~
    I just did some testing, have tried using every method I can think of but nothing seems to work from VBA even sendkeys

    However as soon as I go into a field on the form and type one character, the defaults THEN display.... its very frustrating.


    Jonh ~

    Yes there are the defaults on the form, however the textboxes etc are linked to fields in an SQL database and as such should be using the defaults for that field from the table.
    defaults for the actual control normally only come into play if a control is not linked to a field in a table.




    I have also tried doing form refreshes etc etc

    ~Edit~

    As I was typing this I discovered a combination of commands that appears that it may resolve my problem last item on load is to set focus to a control linked to a field in a table and trigger dirty.

    Me.txtBoxLinkedToField.SetFocus
    Me.Dirty = True
    ~Edit 2~

    Refined to

    Me.Controls(0).SetFocus
    Me.Dirty = True
    "From the ashes of disaster grow the roses of success" - Chitty chitty bang bang

    "I fear not the man who has 10,000 kicks practiced once. I fear the man who has 1 kick practiced 10,000 times" - Bruce Lee

  5. #5
    VBAX Guru
    Joined
    Mar 2005
    Posts
    3,296
    Location
    Well done in getting something to work.
    In line with my original post I was going to suggest having a hidden field (ie not required by the user) that is populated by VBA abd then set focus to the first field, I don't know if it would have triggered the Defaults or not.
    But your method is much more elegant.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •