473,321 Members | 1,669 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,321 software developers and data experts.

Nz function not working

Jerry Maiapu
259 100+
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)

Expand|Select|Wrap|Line Numbers
  1. =Environ("UserName")
However, recently for some Workstations the following showed up in the username text box.
Expand|Select|Wrap|Line Numbers
  1.  #Name?
ie the default value

Expand|Select|Wrap|Line Numbers
  1. =Environ("UserName")
errors out..

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

Expand|Select|Wrap|Line Numbers
  1. =IIf(IsNull(Environ("UserName")),"Enter Username",Environ("UserName"))
  2.  
Expand|Select|Wrap|Line Numbers
  1. =Nz(Environ("Enter UserName"),"UserName")
Can someone help on this..

Thanks

Jerry
Jul 27 '10 #1

✓ answered by doma23

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:
http://bytes.com/topic/access/answer...assword-access

** Edit **
New question separated to Check Credentials against OS.

10 3609
doma23
107 100+
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!
Jul 27 '10 #2
missinglinq
3,532 Expert 2GB
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)>
Jul 27 '10 #3
Jerry Maiapu
259 100+
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=formuser 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?
Jul 27 '10 #4
Jerry Maiapu
259 100+
This does not help as well

Expand|Select|Wrap|Line Numbers
  1. =IIf(IsError(Environ("UserName")),"Enter Username",Environ("UserName"))
Cannot figure out..Hope someone helps
Jul 27 '10 #5
missinglinq
3,532 Expert 2GB
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:

http://www.accessmvp.com/DJSteele/Ac...nceErrors.html

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)>
Jul 27 '10 #6
Jerry Maiapu
259 100+
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
Jul 28 '10 #7
doma23
107 100+
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:
http://bytes.com/topic/access/answer...assword-access

** Edit **
New question separated to Check Credentials against OS.
Jul 28 '10 #8
Jerry Maiapu
259 100+
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
Jul 28 '10 #9
NeoPa
32,556 Expert Mod 16PB
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).
Aug 3 '10 #10
Jerry Maiapu
259 100+
It's done..No Worries
Aug 3 '10 #11

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Andy Fish | last post by:
Hi I am using Xalan-J 2.4.1 and I am trying to get the EXSLT node-set function working. xalan:nodeset() works fine but when I try exslt:node-set I get this error: (Location of error...
0
by: adamsbarker | last post by:
i can't seem to get the "ssh2_exec" function working on Windows XP. the example in the manual (which is obviously linux biased) says: ssh2_exec($connection, '/usr/local/bin/php -i'); i have...
1
by: Julie May | last post by:
I have 90% of my function working and I know to get the next 10% it is justa matter of getting the quotations and the escaping quotations correct. Here is the portion that does work: <working...
4
by: Olex Malko | last post by:
How to manage FindWindow() function working properly in ASP.NET application? In Windows Forms application it works fine. But in ASP.NET it returns NULL :( Probalby this is because of different...
6
by: Rudy | last post by:
Having problems getting the PMT function working. I'm new to programming, and I read the tech notes On how to set up. But it still doesn't work. Can somebody just give me an example the proper way...
1
by: Graeme Hinchliffe | last post by:
Hiya, I have written a C function for postgres. I developed and got this function working on postgres 7.3.2, however the production system was 7.4.3. On my initial dev setup it worked...
1
by: tkkarthik | last post by:
Hello everyone.. Let me tell where i am in my programming.. I have 3 command buttons in my form. say a, b,c When I press the Key A in keyboard, I need the color of my command buton A to...
0
by: M Cavanagh | last post by:
I am fairly new using functions to return file info and I made an assumption that a function working on a local machine would work fine on a server. I have searched several Access books to find a...
19
by: Adam | last post by:
Hi, I'd like to return an (arbitrary length) string array from a function so that after calling the array I've got a list of strings I can access. After much perusing of the internet I found a...
3
by: dkyadav80 | last post by:
Hi sir, I'have written small function in javascript for date (month and year), this is good working in IE at onclick event and current month-8 , year-2008 are displaying but in firefox3,opera,&...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.