Nz function not working

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Jerry Maiapu
    Contributor
    • Feb 2010
    • 259

    Nz function not working

    Hi there,
    I have a log in form that users use to log in to the ACCESS DB.
    The username and password are taken from the current logged in user of the windows.

    I have put the following as the default value for the
    username text box which works fine.
    ( Takes the current logged in user and punches it into txtusername)

    Code:
    =Environ("UserName")
    However, recently for some Workstations the following showed up in the username text box.
    Code:
     #Name?
    ie the default value

    Code:
    =Environ("UserName")
    errors out..

    How can I solve this? I have tried to put some other text to fabricate the error but its persistent.

    Code:
    =IIf(IsNull(Environ("UserName")),"Enter Username",Environ("UserName"))
    Code:
    =Nz(Environ("Enter UserName"),"UserName")
    Can someone help on this..

    Thanks

    Jerry
  • doma23
    New Member
    • May 2010
    • 107

    #2
    Hi there, I don't know the answer to your question.
    But I would like to ask you something.
    Your form takes the current user's Windows username automatically with ENVIRON function, then user enters the password and code checks if it's correct password (the same one that user uses to login to Windows).
    Is this correct?
    If so, could you tell me how did you setup the procedure for the password to be checked?
    Tnx a lot!

    Tnx!

    Comment

    • missinglinq
      Recognized Expert Specialist
      • Nov 2006
      • 3533

      #3
      I think your thread title is somewhat misleading as your problem really isn't that the Nz() function is not working but rather that Environ() is working!

      I suspect that the errant workstations are either running new versions of Access or someone has diddled with their settings. With v2003 Microsoft introduced the "Sandbox Mode" to basically protect people from themselves! Under this mode Access "protects" you by not allowing "dangerous" expressions to run. Unfortunately, Access apparently considers its own functions Environ() and CurDir() to be "dangerous" and blocks them as well!

      You have the option of disabling Sandbox Mode by setting the macro security level to Low.

      Linq ;0)>

      Comment

      • Jerry Maiapu
        Contributor
        • Feb 2010
        • 259

        #4
        Thanks missingling for the title correction, my fault..

        Ok, regarding what doma23 raises, well, to answer that,I have a API function that deals with retrieving windows password and users (currently logged in). It compares, if currentuser=for muser and currentpassword =formpassord then validation successful.

        That function is fine as far as I am concerned.

        I already disabled the Sandbox Mode by setting the macro security level to Low but this does not solve.

        Any other suggestion?

        Comment

        • Jerry Maiapu
          Contributor
          • Feb 2010
          • 259

          #5
          This does not help as well

          Code:
          =IIf(IsError(Environ("UserName")),"Enter Username",Environ("UserName"))
          Cannot figure out..Hope someone helps

          Comment

          • missinglinq
            Recognized Expert Specialist
            • Nov 2006
            • 3533

            #6
            What version of Access are we talking about on the errant machines?

            And any time that apps run fine on one machine and not on another or run fine in one version and not when run under a newer version, one thing you always have to think about are missing references.

            If you're not familiar with checking for missing references, here are Doug Steele's detailed instructions on how to troubleshoot them:



            Linq ;0)>

            P.S. Just noticed that you are located in PNG! My father spent some time in port in Port Moresby, during WWII, and was still talking about it years later! Actually it was the only part of the war he ever talked about!

            Linq ;0)>

            Comment

            • Jerry Maiapu
              Contributor
              • Feb 2010
              • 259

              #7
              Thanks missinglinq for the help.. Well I have tested my db on MS2003 and MS 2007 and its fine. I have also Compiled the db project and no error ( successful).

              Maybe some required references are missing or not included/selected so I'll go throuhg the link you specified and update.

              NB:I am a Papua New Guinean and am currently living in the capital, Port Moresby (coast)though am from the Highlands regions (from the mountains).

              If your father is still living then tell him that "A gentlemen from PNG has thanked you for being his hero in WWII".

              Because of the sacrifices of soldiers like your father we are free and were able to get independence. (1975)

              So tell him that he is my hero, a hero my country.

              23rd of September is our Remembrance Day for WWII and that was last week Friday according to time on this side. Every indigenous who participated in assisting the Australians and American soldiers are given special recognition awards by the Australian and PNG governments.It is also a special public holiday that we pay tribute to those who lost their lives during WWII. (esp. in Kokoda Track were many Japanese and American+Australians soldiers lost their lives)

              Tell your father that Port Moresby has quite changed now including the port. And ya hoping that he or his family members come for a visit. Many things to discover...land of unexpected..

              Regards

              JM

              Comment

              • doma23
                New Member
                • May 2010
                • 107

                #8
                Nz function not working

                For your problem with environ(), I've stumbled on a topic on this forum where one user ran into similar troubles, and he found solution by implementing special function insted of environ() for retrieving the current user's username.
                Take a look:


                ** Edit **
                New question separated to Check Credentials against OS.
                Last edited by NeoPa; Aug 3 '10, 01:05 PM. Reason: Edited to reflect moving of question to separate thread

                Comment

                • Jerry Maiapu
                  Contributor
                  • Feb 2010
                  • 259

                  #9
                  Thanks for the link.

                  I'll try and give you what you are asking for but I need to edit/modify so that it is generally suits you situation.

                  JM

                  Comment

                  • NeoPa
                    Recognized Expert Moderator MVP
                    • Oct 2006
                    • 32656

                    #10
                    My ability to set Best Answer has gone Jerry ;(

                    Can you set Doma's post #8 back again for me please (I made an initial mistake of moving the original post first instead of copying it, so I copied it back in here. That caused the Best Answer to link to the edited post in the other thread instead of the one in here that had the relevant info in).

                    Comment

                    • Jerry Maiapu
                      Contributor
                      • Feb 2010
                      • 259

                      #11
                      It's done..No Worries

                      Comment

                      Working...