A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » General Discussion
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

CurrentUser() returns null



 
 
Thread Tools Display Modes
  #1  
Old September 4th, 2008, 03:26 PM posted to microsoft.public.access,comp.databases.ms-access
Mourad[_2_]
external usenet poster
 
Posts: 39
Default CurrentUser() returns null

Hi All,

CurrentUser() returns null when called from a form event handler, at
least from Form_Open()!

However, it works fine in other forms!

Use Application.CurrentUser seem to work, but I'd rather get
CurrentUser() to work, since there are so many calls to it.

Thanks for reading,

Mourad

  #2  
Old September 4th, 2008, 03:34 PM posted to microsoft.public.access,comp.databases.ms-access
Dirk Goldgar
external usenet poster
 
Posts: 2,529
Default CurrentUser() returns null

(re-posting, as my original reply hasn't appeared)

"Mourad" wrote in message
...
Hi All,

CurrentUser() returns null when called from a form event handler, at
least from Form_Open()!

However, it works fine in other forms!

Use Application.CurrentUser seem to work, but I'd rather get
CurrentUser() to work, since there are so many calls to it.



My guess is that you have something else named CurrentUser that is in scope
at the time you call it from this form's Open event. Do you have a control,
field, or variable named CurrentUser?

--
Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)

  #3  
Old September 4th, 2008, 04:59 PM posted to microsoft.public.access,comp.databases.ms-access
Mourad[_2_]
external usenet poster
 
Posts: 39
Default CurrentUser() returns null

Thanks Dirk,

Nop! There is no user defined CurrentUser() anywhere in the code.

The debugger even does not step into CurrentUser() function!

It still returns null!!

Thanks,

Mourad
  #4  
Old September 4th, 2008, 05:23 PM posted to microsoft.public.access,comp.databases.ms-access
Dirk Goldgar
external usenet poster
 
Posts: 2,529
Default CurrentUser() returns null

"Mourad" wrote in message
...
Thanks Dirk,

Nop! There is no user defined CurrentUser() anywhere in the code.

The debugger even does not step into CurrentUser() function!



If the "CurrentUser" function you are referring to is the built-in one, I
wouldn't expect the debugger to step into it.

If you click Debug -Compile in the VB editor, are any compile errors found?

The fact that it works in other forms but not in one particular form
strongly suggests that there's something about that particular form that is
the problem. If you create a new database, import that form and any
necessary supporting tables, queries, and modules into it, does the call to
CurrentUser work on the form in that database?

If not, and if you want to send me a (zipped) copy of that database to look
at, you can send it to the address you get by removing "NO SPAM" and
".invalid" from the reply address of this message.

--
Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)

  #5  
Old September 5th, 2008, 08:34 AM posted to microsoft.public.access,comp.databases.ms-access
Keith Wilby
external usenet poster
 
Posts: 812
Default CurrentUser() returns null

"Mourad" wrote in message
...
Thanks Dirk,

Nop! There is no user defined CurrentUser() anywhere in the code.

The debugger even does not step into CurrentUser() function!

It still returns null!!


What happens if you type ?CurrentUser into the immediate window?

Keith.

  #6  
Old September 5th, 2008, 09:19 AM posted to microsoft.public.access,comp.databases.ms-access
Brendan Reynolds
external usenet poster
 
Posts: 1,241
Default CurrentUser() returns null

"Mourad" wrote in message
...
Thanks Dirk,

Nop! There is no user defined CurrentUser() anywhere in the code.

The debugger even does not step into CurrentUser() function!

It still returns null!!

Thanks,

Mourad



The data type of the return value of the built-in CurrentUser() function is
String, which can never be Null, so if you have something called
CurentUser() that is returning Null, it is not the built-in function, it
can't be, as in order to return Null the data type of its return value has
to be Variant.

--
Brendan Reynolds

  #7  
Old October 23rd, 2008, 08:50 PM posted to microsoft.public.access,comp.databases.ms-access
Mourad[_2_]
external usenet poster
 
Posts: 39
Default CurrentUser() returns null

Thank you all,

It was found that the underlying query of the form has a column with
the same name, CurrentUser! It seems that Access refers to this one
when CurrentUser() function is called! So when the query returns no
rows, CurrentUser() returns NULL, but if there is one or more rows, it
returns a contents of some row (didn't verify which)

I doubt this is by design! I believe it is an Access bug!

Mourad
  #8  
Old October 23rd, 2008, 09:18 PM posted to microsoft.public.access,comp.databases.ms-access
Douglas J. Steele[_3_]
external usenet poster
 
Posts: 3,143
Default CurrentUser() returns null

I don't believe it's not a bug.

If you mistaken choose to name something with a reserved name, Access will
try to respect your object. This allows you to override built-in
functionality (although realistically it's not a good idea).

For a comprehensive list of names to avoid, see what Allen Browne has at
http://www.allenbrowne.com/Ap****ueBadWord.html Note that there's also a
link at the top of the page to a utility that will help identify names
you've used by mistake.

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no private e-mails, please)


"Mourad" wrote in message
...
Thank you all,

It was found that the underlying query of the form has a column with
the same name, CurrentUser! It seems that Access refers to this one
when CurrentUser() function is called! So when the query returns no
rows, CurrentUser() returns NULL, but if there is one or more rows, it
returns a contents of some row (didn't verify which)

I doubt this is by design! I believe it is an Access bug!

Mourad



  #9  
Old October 23rd, 2008, 09:22 PM posted to microsoft.public.access,comp.databases.ms-access
Douglas J. Steele[_3_]
external usenet poster
 
Posts: 3,143
Default CurrentUser() returns null

Darn double negatives!

I meant to say "I don't believe it's a bug"!

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no private e-mails, please)


"Douglas J. Steele" wrote in message
...
I don't believe it's not a bug.

If you mistaken choose to name something with a reserved name, Access will
try to respect your object. This allows you to override built-in
functionality (although realistically it's not a good idea).

For a comprehensive list of names to avoid, see what Allen Browne has at
http://www.allenbrowne.com/Ap****ueBadWord.html Note that there's also a
link at the top of the page to a utility that will help identify names
you've used by mistake.

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no private e-mails, please)


"Mourad" wrote in message
...
Thank you all,

It was found that the underlying query of the form has a column with
the same name, CurrentUser! It seems that Access refers to this one
when CurrentUser() function is called! So when the query returns no
rows, CurrentUser() returns NULL, but if there is one or more rows, it
returns a contents of some row (didn't verify which)

I doubt this is by design! I believe it is an Access bug!

Mourad





  #10  
Old October 23rd, 2008, 10:01 PM posted to microsoft.public.access,comp.databases.ms-access
lyle fairfield
external usenet poster
 
Posts: 24
Default CurrentUser() returns null

On Oct 23, 3:50*pm, Mourad wrote:
Thank you all,

It was found that the underlying query of the form has a column with
the same name, CurrentUser! It seems that Access refers to this one
when CurrentUser() function is called! So when the query returns no
rows, CurrentUser() returns NULL, but if there is one or more rows, it
returns a contents of some row (didn't verify which)

I doubt this is by design! I believe it is an Access bug!

Mourad


When we preface a function with the Class of which it is a member
Access can often differentiate between objects with the same name.
Otherwise it uses the first one it comes to as it searches through all
the classes and pointers currently in scope; I believe this search is
ordered descending on creation time.
You may be able to help Access/VBA understand what you want with
Access.CurrentUser() or Application.CurrentUser(); this syntax will
tell Access/VBA where to look.
I often use VBA.Date() as, despite many warnings that the sky will
fall I like to call my Date fields, "Date", unless I call them
"Redhead" but that is another story. Works swimmingly!
There's no bug here. Access is not Aladdin's lamp. It cannot magically
decide which CurrentUser you want.
BTW, I recall only one genuine bug posted here in CDMA, (many years
ago).
 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 05:57 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.