How should I go about editing a public variable in a subform from a completely separa

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • SourceOfAccess
    New Member
    • Nov 2015
    • 6

    How should I go about editing a public variable in a subform from a completely separa

    I have 3 different forms:

    - Login
    - Navigation
    - Welcome

    The form Navigation has a Navigation Control that displays the form Welcome as a subform.

    In the form Welcome, there is a public variable as following:

    Public trueLoginName As String

    While is the form Login, there is a Dim bariable as following:

    Dim trueLoginId As String

    I need to somehow set trueLoginName = trueLoginId in the Login form. Any ideas? Thanks!
  • nico5038
    Recognized Expert Specialist
    • Nov 2006
    • 3080

    #2
    Hard to follow.
    I normally have a tblLogin with the userid's allowed to use the application and use a DLOOKUP() to verify or the entered username is in this table.
    Another option with no username typing is to use the Windows user with:
    Code:
    if not DLOOKUP("txtLogin","tblLogin",Environ("username")) is null then
     'action OK
    else
     'action not ok
    endif
    Thus only allowed users from the table are granted access.

    Comment

    • SourceOfAccess
      New Member
      • Nov 2015
      • 6

      #3
      Thanks for your reply Nico. But I don't think you understand the issue at hand - I apologise for not being clear enough.

      Essentially what I'm trying to do is input the ID of the user into a text box on a subform that's under a navigation form which opens when the login process is successful.

      Comment

      • nico5038
        Recognized Expert Specialist
        • Nov 2006
        • 3080

        #4
        You can use the same DLOOKUP to assign the ID in the OnOpen event:
        me.txtIDfield = DLOOKUP("trueLo ginID","tblLogi n",trueLoginNam e)

        Comment

        • zmbd
          Recognized Expert Moderator Expert
          • Mar 2012
          • 5501

          #5
          + Lets start with the fact that the navigation form (NCF), navigation control is not the normal parent/child relationship in that what happens is that every time you change the form shown in the NCF-Subform-Container (NCFSFC) via one of the NCF-Buttons (NCFB) (Do NOT confuse these with tabs - these are special type of control see my post here z's-NvCtrl) the form associated with the NCFB is loaded fresh and everything on the prior form is saved to the bound recordsource or is lost. Even if you click on the same NCFB that loaded the currently shown subform in to the NCFSFC the bound record is saved and/or the value entered in to the unbound control is lost

          + Now what I have done is moved to the new Tempvars.object . Use this object and set member of the collection to your value. This method is truly global to the application and persists until either the member of the collection is removed or the current database is closed.
          Last edited by zmbd; Nov 28 '15, 06:49 PM.

          Comment

          Working...