Results 1 to 3 of 3
  1. #1
    gemadan96 is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Oct 2012
    Posts
    110

    Default Value in Forms based on value in another table

    I have an Access 2007 database to manage tournament registrations. This


    database will contain information for many different events, but only one
    tournament will be active at any one time. It will be used by others that are
    not access knowledgeble, so I need to make it as user friendly as possible.

    Among the tables I have are Settings, Tournaments, and Registrations.
    Settings identifies the current tournament. Tournaments identifies each
    tournament and its various fees. Registrations contains info about each
    registration including the tournament and the competitor. Settings and
    Registrations each have a lookup field tied to the TID (Autonumber, primary key)
    field of Tournaments.

    I have a form, Set Current Tournament, that allows the user to set the
    tournament in the Settings table.

    I have a query, Registrations Extended, which calculates other values based
    on the registration.

    I have a form called Registration, used to enter the registration
    information. That form includes a field (control) for the TID to select the
    tournament to register for. I want that field (control) to have a default value
    of the Current Tournament in the Settings table. I've tried a dlookup with no
    success.

    If it were just me using the database I would just change it manually,
    however like I said the primary users won't be able to do that without getting
    flustered.

    Any sugeestions? Maybe a macro or VBA? Just need to know how to do it.

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    Could try code in the form Open event to set the DefaultValue property, something like:

    Me.controlname.DefaultValue = DLookup("ID","Tournaments","Active=-1")
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    gemadan96 is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Oct 2012
    Posts
    110
    I tried the following suggestion from another forum and it worked perfectly.

    Create a function in a Standard Module (not form,
    report, or class module) like this:



    Code:

    Function GetDefaultTID() As Long GetDefaultTID = Nz(DLookup("YourFieldNameWhichHasTheSetting", "YourSettingsTableHere"), 0)End Function
    and set the DEFAULT
    VALUE property for the control in the form to

    =GetDefaultTID()

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

Similar Threads

  1. Forms Default Date
    By smarty84handsome in forum Forms
    Replies: 2
    Last Post: 01-09-2012, 07:15 PM
  2. Replies: 4
    Last Post: 12-21-2011, 02:45 AM
  3. Replies: 3
    Last Post: 07-30-2011, 09:12 PM
  4. Default Forms
    By BigCat in forum Forms
    Replies: 10
    Last Post: 06-09-2011, 03:36 PM
  5. Two Forms based on One Table
    By blueraincoat in forum Forms
    Replies: 10
    Last Post: 05-22-2011, 11:17 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