Newbie - Passing info between forms

bodhran1

Dazed and Confused
Local time
Today, 13:16
Joined
Mar 27, 2002
Messages
43
My first form opens a VB script that compares a users name to their password which is stored in an Excel database.

Several forms later, I need the users name again. I assigned it to a string called "username" but once I close that first form it seems to lose it?

Here's where it gets trickier:

I would write it to a temp file, but this program is on a network and could be accessed by many users at once.

A temp file might get overwritten by another user. Especially when they come back to finish a job days later.

Next complication (or challenge, depending how you look at it) is, some users have access to multiple computers and may not complete the job on the computer they started with.

Final challenge: Users may have several of these "temp" files running at once.

Aaaarrrgghhh!!!!

I hope you can help me.

Plese reply here or to:

dpasquino@actechdrives.com
 
>Several forms later, I need the users name >again. I assigned it to a string >called "username" but once I close that
>first form it seems to lose it?

Create a new module.

Put the variable definition in the module declarations section:

Ex.:

Dim gstrUserName as string

Use this module variable instead of the local form module variable to hold the user name.

Hope this helps,

Peter De Baets
Peter's Software - MS Access Tools for Developers http://www.peterssoftware.com
 
What "username" are you referring to? You can get the Network user name with the fOSUserName() function (check the archives) for earlier versions of Windows or Environ("UserName") for Win2k+. You should be able to use CurrentUser if you use Access workgroups/security, but I don't so I can't speak to that directly. Again, check the archives.

I'm not sure how you are using this information. Are you just trying to make sure the same user always gets the same records? Store the username in the record and filter it by that when you open their form.

HTH,
David R
 

Users who are viewing this thread

Back
Top Bottom