Results 1 to 6 of 6
  1. #1
    veejay is offline Advanced Beginner
    Windows 7 32bit Access 2007
    Join Date
    Nov 2018
    Location
    Montreal, Canada
    Posts
    46

    Question Keep default value for combo box until close?

    I have a form which is on a shared drive and have about 5 users using it.
    There is a combo box in one of the form which is basically a list of their names.
    When they are filling a form they need to select who's doing the review.

    I was wondering if it's possible to default the value to a previous selection.

    To be clear here's what I would like to do:

    On the first form which is "Front page" they have a button to open the form, generate a report or have instruction.
    On the second form which is "Review form" they have a combo box where they select their name for EACH new record.


    I would like to add a new combo box on the "Front Page", so they can select their name ONCE and this combo box would serve as the default for the "Review form" which is where the actual combo box is.

    Any help with this?



    More information about a possible other way to achive this:




    I have a module that I use to record the "UserID" from their computer, would something like this work to set the default?

    The module is like this:

    Code:
    Private Declare Function apiGetUserName Lib "advapi32.dll" Alias _
        "GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long
    Function fOSUserName() As String
    ' Returns the network login name
    Dim lngLen As Long, lngX As Long
    Dim strUserName As String
        strUserName = String$(254, 0)
        lngLen = 255
        lngX = apiGetUserName(strUserName, lngLen)
        If lngX <> 0 Then
            fOSUserName = Left$(strUserName, lngLen - 1)
        Else
            fOSUserName = ""
        End If
        End Function
    and I have a field called "UserID" on my form which records the UserID.

    The list of users is in a table called "UserTable" with an ID and their name. Could I add a row to match it with their userID?

  2. #2
    davegri's Avatar
    davegri is offline Excess Access
    Windows 10 Access 2016
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,388
    Do it the other way around.
    Add an unbound textbox to hold the name. Then when a name is selected from the combobox, put that name in the textbox.
    That name will remain in the textbox until the form closes, and can be used as the default.

    I hope you don't really mean you have an entire DB or an FE from a split database on a share for all 5 users. In that case, my solution won't work, and your DB won't work very long either.
    If this doesn't make sense, Google "Why to split an Access database".

  3. #3
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,816
    Use code in original combobox AfterUpdate event to set its DefaultValue property. However, not sure how this will work with multiple users opening the same file.

    I have developed a non-split db that was simultaneously used by multiple users (that's what they wanted). It did work but there was absolutely no code, not even macros. A very simple, small db.
    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.

  4. #4
    veejay is offline Advanced Beginner
    Windows 7 32bit Access 2007
    Join Date
    Nov 2018
    Location
    Montreal, Canada
    Posts
    46
    Will it work on a split database? My backend is stored in a different place and my users only have access to the front end of it?

  5. #5
    orange's Avatar
    orange is online now Moderator
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,716
    veejay,

    How about giving readers the 30,000 ft overview of what your business is in simple plain English? It will help you and readers to communicate and focus ideas/advice with that context.
    You could create a Login form and get and match user credentials. See this thread for more info.

    Good luck with your project.

  6. #6
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,816
    Of course works with split db. The concern is whether or not each user runs their own copy of frontend installed on their workstation.

    Person doing data input will be same person doing review? If yes, a user login form might be useful (or annoying). It is possible to grab user info without user even being aware of this and they don't have to make selection in combobox. Have a table of users with a field for the network USERNAME. Grab the network USERNAME and use it to do lookup to the Users table. One way to grab network user name is with Environ("USERNAME"). This will pull user name of person logged into network on that computer.
    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.

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

Similar Threads

  1. Replies: 2
    Last Post: 04-27-2016, 03:34 AM
  2. Combo Box Default Value / Help Text,
    By jerem in forum Forms
    Replies: 3
    Last Post: 07-16-2014, 06:29 PM
  3. Replies: 2
    Last Post: 05-05-2013, 09:07 PM
  4. Default value for cascading combo box
    By wwjd80 in forum Forms
    Replies: 1
    Last Post: 06-28-2010, 05:57 PM
  5. Default Value for Cascading Combo Box
    By P5C768 in forum Forms
    Replies: 3
    Last Post: 05-06-2010, 03:50 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