Smart questions
Smart answers
Smart people
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Member Login




Remember Me
Forgot Password?
Join Us!

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips now!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

Join Tek-Tips
*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Donate Today!

Do you enjoy these
technical forums?
Donate Today! Click Here

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.
Jobs from Indeed

Link To This Forum!

Partner Button
Add Stickiness To Your Site By Linking To This Professionally Managed Technical Forum.
Just copy and paste the
code below into your site.

NNNNN (MIS)
17 Jan 06 16:05
Hi I have created a data access page in Microsoft Access

The page is based on a query which I would like to set the criteria to the current Windows logged in user

I tried using environ("username")  I am told that VBA does not work in VB Script

How on earth Can I get it to work so that when a user opens the data page from internet explorer they can see only the records based on  their user name and not the whole table with everyone else's records?


Any help would be VERY much appreciated


snotmare (Programmer)
17 Jan 06 16:29
Greetings!

I've you're simply talking about the Windows login user ID, then you can grab it this way...

CODE

Dim objNetwork

Set objNetwork = CreateObject("WScript.Network")

MsgBox objNetwork.UserName

He who has knowledge spares his words, and a man of understanding is of a calm spirit. Even a fool is counted wise when he holds his peace; when he shuts his lips, he is considered perceptive.   - King Solomon

NNNNN (MIS)
17 Jan 06 16:48
Thanks for your quick reply

Ithe code looks good,  but I am not sure where exactly to put it

I hav eput it in the scripting editor in different places but get errors and I can see how to do this

Do I put objNetwork.UserName in the query critera?

Thanks again

EBGreen (Programmer)
17 Jan 06 16:55
If this is an ASP page you may need to do Server.CreateObject instead of just CreateObject.

"... isn't sanity really just a one trick pony anyway?!  I mean, all you get is one trick, rational thinking, but when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick

NNNNN (MIS)
17 Jan 06 17:07
Thanks

Please excuse my ignorance

this is my first time for data access page

I pt the code in
MSMODCSC  OnCLick

<SCRIPT language=vbscript event=onclick for=MSODSC>
<!--
Dim objNetworkSet objNetwork =Server.CreateObject("WScript.Network")
MsgBox objNetwork.UserName
-->
</SCRIPT>

The error is complaining aboutr this line  <!--

I have removed it. cghanged it but no good

I am assuming that the code goes somewhere in the VBSCript and not in the the in VBA Function?

Thanks Again
Skie (Programmer)
17 Jan 06 20:06

CODE

Dim objNetwork
Set objNetwork = CreateObject("WScript.Network")
strUserName = objNetwork.UserName
MsgBox strUserName

Your set is on the same line as your dim.
strUserName is a variable you can use.
Msgbox is just notifying you of the username it grabbed.
NNNNN (MIS)
18 Jan 06 15:18
Hi

Well Ididn't get any errors but n o message either

If I use the following

msgbox("hi")
Dim objNetwork
Set objNetwork = CreateObject("WScript.Network")
strUserName = objNetwork.UserName
MsgBox strUserName

I get a message saying Hi
nut no other message with username

Thanks
tsuji (TechnicalUser)
19 Jan 06 9:02

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Back To Forum

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close