Results 1 to 4 of 4
  1. #1
    kevdillon is offline Novice
    Windows 10 Access 2016
    Join Date
    Mar 2020
    Posts
    4

    Load a form based on a field value

    Is there a way to load a form based on a value in a table? I don't want a menu showing all the forms that are available, only a specific form based on the value in a table. I simply need a way for a user to immediately return to the form they were in the last time they used the db.



    I currently have a table that is updated by a query each time another form in the db is opened. It therefore only contains 1 field and 1 record at any point in time. Each user has their own copy of the db (they are not all sharing).


    I haven't used Access in years so my knowledge of code etc is very vague.

    I've spent days trying to get this to work. I've tried hyperlinks, command buttons, subforms (trying to make them visible/ invisible) etc. The only other thing I can think of is to set up a password system whereby a user records a code on the form they are working on and inputs this to load the form at startup.

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    With a 1 record table you could use DLookup() with no criteria to get the form name and open it. That could be in an autoexec macro maybe, or a form that opens with the db, opens the desired form, then closes the startup form.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    kevdillon is offline Novice
    Windows 10 Access 2016
    Join Date
    Mar 2020
    Posts
    4
    Thanks for your response. I have looked at using the DLookup function but got a bit lost.
    My table is called LoadLevel. The field is called Level.
    Currently, the value in this field will change each time a new form opens. For example, it might say "Shortlist" or "WelcomeAboard".
    The corresponding form for each is "b ShortList" and "c WelcomeAboard".

    Could you give me a bit more info on how I could open one of these forms based on the field value in the table? What would the code look like or how could I set up the autoexec macro?

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    Not on a computer right now but along the lines of

    Dim strFormName As String

    strFormName = DLookup("Level", "LoadLevel")
    DoCmd.OpenForm strFormName
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

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

Similar Threads

  1. Replies: 1
    Last Post: 03-26-2019, 05:20 PM
  2. Set Focus to a field on Form Load
    By swenger in forum Forms
    Replies: 4
    Last Post: 08-23-2016, 11:58 AM
  3. Replies: 3
    Last Post: 04-10-2015, 10:26 PM
  4. Replies: 9
    Last Post: 08-13-2014, 07:55 AM
  5. load form based on report
    By bigmac in forum Reports
    Replies: 1
    Last Post: 05-01-2012, 09:33 AM

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