Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to get the application name? 1

Status
Not open for further replies.

6ftAndClean

Programmer
Sep 24, 2003
19
GB
I have a database which is to be used by 4 users. I intend setting things up so that there is one backend and 4 x frontends. Each frontend will have it's application name (seen in the main application titlebar) set by the following format: "<project name> - <user name>"

Since I have made it possible for each user to store preferences for how they view the frontend (details of which are stored in a "userPrefs" table) I would like the application to automatically detect which user it is dealing with. I know there are grown-up ways of interogating the OS to determine the logon name etc. but what I would like to do (because it seems like it should be a simple thing to do) is to just return the user name from the application title. What I can't figure out is how to access the application name via VBA.

Suggestions please.

Thanks,

Nick

PS I know this method sounds a little cranky and not v
robust/professional but the situation for which I am programming is also a little cranky and wierd and, on balance, this method seems like the best option although, if you have a better suggestion please suggest it!.
 
I think you can reach it through

[tt]currentdb.properties("AppTitle")[/tt]

Be aware though, that if you haven't assigned anything here, you'll probably get a 3270 (Property not found) error, which means you have to create it first.

Roy-Vidar
 
No sure if this is what your after but you could use an If Then statement in conjunction with CurrentUser in something like the OnOpen property of your startup form.

But I think you'll have to rework the way your handle user preferences otherwise you could end up amending the startup form every time a new user comes along.




 
How are ya 6ftAndClean . . .

[blue]Roy Vidar[/blue] is on target. Try this:
Code:
[blue]Public Function AppUser()
   Dim Title As String, idx As Integer
   
   Title = CurrentDb.Properties("AppTitle")
   idx = InStr(Title, "-")
   AppUser = Right(Title, Len(Title) - idx - 1)

End Function[/blue]

Calvin.gif
See Ya! . . . . . .
 
i'm only a little lost. you mention the four fron-ends, implying that these are "resident" on the individual workstations. Then note that the application title will include the users name / handle. I don't quite see how the app title will include the users name, unless it is stored in the application (FE) as part of the app itself. If it is, then it seems useless to need to access it, since (for a given installation) it is a constant. If it is not part of the local app, then it cannot be set unless / until you ascertain who hte individual user is, so it remains an un-necessary detour to whereever you are really trying to go with this thread.

If the workstations are used by the single individual, abreviating the user preferences table to the single user and storing it as part of the FE is all that is necessary. Otherwise, some real form of returning hte username is necessary. If you have implemented (Ms. A.) security, the 'username' property is sufficient otherwise you will need to do the grownup thing and get the OS username (and -of course-) require OS log on to access the app.

Since so many others are offering other advice, I'm sure i'm just not understanding something, so I'm well braced for the onslought of explination ...




MichaelRed


 
Thanks Roy-Vidar and TheAceMan1. I'll be following up your advice directly.

MichaelRed, in almost all respects you are, of course, right. The thing is that I am trying to avoid anything to do with the normal route of implementing security etc (does not matter if this data is secure or not). Therefore, there is no 'username' property to examine.

I could equally set up a global variable and edit the code for each of the 4 frontends. However, I like the way my method enables me and the users to be sure of which set of preferences is in use by visual reference to the titilebar of the application. It also allows the user prefs to be changed non-codally by just changing the app name via Tools > Startup.

I'm probably v guilty of trying to do things in way which suits me and not the way Access was designed to be used. I can't see why I shouldn't go down this path but if anyone feels the need to put me straight then please feel free. :)
 
Thanks TheAceMan1[/color blue], your code hit the spot very nicely thank you. I did add the following line:

Code:
AppUser = Trim(AppUser)

just to tidy up the returned username.

Thanks again,

Nick
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top