473,388 Members | 1,188 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,388 software developers and data experts.

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

Sep 4 '08 #1
10 2492
(re-posting, as my original reply hasn't appeared)

"Mourad" wrote in message
news:92**********************************@i20g2000 prf.googlegroups.com...
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)

Sep 4 '08 #2
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
Sep 4 '08 #3
"Mourad" <mo************@gmail.comwrote in message
news:a3**********************************@a18g2000 pra.googlegroups.com...
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)

Sep 4 '08 #4
"Mourad" <mo************@gmail.comwrote in message
news:a3**********************************@a18g2000 pra.googlegroups.com...
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.

Sep 5 '08 #5
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
Oct 23 '08 #6
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/AppIssueBadWord.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" <mo************@gmail.comwrote in message
news:78**********************************@s50g2000 hsb.googlegroups.com...
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

Oct 23 '08 #7
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" <NOSPAM_djsteele@NOSPAM_gmail.comwrote in message
news:OV**************@TK2MSFTNGP06.phx.gbl...
>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/AppIssueBadWord.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" <mo************@gmail.comwrote in message
news:78**********************************@s50g2000 hsb.googlegroups.com...
>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


Oct 23 '08 #8
On Oct 23, 3:50*pm, Mourad <mourad.bara...@gmail.comwrote:
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).
Oct 23 '08 #9
If Access cannot distinguish "CurrentUser" from "CurrentUser()" then
you have a point! May be it is the way Access works.

But they should not the same: the first is a reference to a variable,
table field, or an object property, but the later is a Function Call!

This concept is in some other languages like C++!

Thanks for your input

Mourad
Oct 23 '08 #10

"Mourad" <mo************@gmail.comescreveu na mensagem
news:78**********************************@s50g2000 hsb.googlegroups.com...
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
Oct 25 '08 #11

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Rene van Hoek | last post by:
Hi, I am using Xalan 1.8.0 and Xerces 2.6.0 in C++. I have an XML document which I first transform into an other XML document using an XSL styelsheet. Then I want to parse with XPathEvaluator...
4
by: ezra epstein | last post by:
Aother head banger for me. Below is a complete example of the code Using Postgres 7.4, the function "test" gets this: psql:temp3.sql:10: ERROR: syntax error at or near "%" at character 135...
2
by: Mark Flippin | last post by:
I'm converting an Access 2000 database (fe/be) to a SQL Server 2000 backend. This is a quick and dirty conversion, using linked files via a file dsn, and is to be completed ASAP with minimal...
10
by: Lyle Fairfield | last post by:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbaac11/html/acfctNZ_HV05186465.asp "If the value of the variant argument is Null, the Nz function returns the number zero or a...
4
by: Henning M | last post by:
Hej All Im relativ new to VB.net and im trying to collect som device information using cfgmgr32.dll I use - Declare Function GetListLength Lib "cfgmgr32.dll" Alias...
6
by: reidarT | last post by:
How do I get current user logged in with vb.net code? reidarT
12
by: robertino | last post by:
Hi all, I've put together a few SPs to produce a BOM (bill of materials) listing, which together use a couple of global temp tables, and return the results from a cursor. Here's the code: ...
1
by: asilter | last post by:
Hi, I'm trying to assign variables where vpSec0 points. void * vpSec0 = NULL; CreateHVFESection0(vpSec0); CreateHVFESection0 function is below.
3
by: JohnHo | last post by:
This is probably simple but this is the last feature for an db app and I am stumped (read fatigued). I have created users with the Access security feature. Additionally, I have a lookup table...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.