Determining Own Filename (1 Viewer)

MikeAngelastro

Registered User.
Local time
Today, 14:38
Joined
Mar 3, 2000
Messages
254
Hi,

Is there a way with code to determine the filename of the Access application that a user is in or at least what folder it's in?

The reason is that I want to enable/disable functional modules based on it. For instance, if the file name were "Acctg_Warehouse.mdb," then enable only the modules appropriate to the warehouse folks. If the file name were "Acctg_Sales.mdb," then enable only the modules for the sales folks.

I know it's possible using Access security, but I don't have that option in my situation.

Thanks,

Mike
 

Fornatian

Dim Person
Local time
Today, 21:38
Joined
Sep 1, 2000
Messages
1,396
CurrentDb.Name will return the full path and name.
 

MikeAngelastro

Registered User.
Local time
Today, 14:38
Joined
Mar 3, 2000
Messages
254
Thanks Ian! I'll try that.
 

ghudson

Registered User.
Local time
Today, 16:38
Joined
Jun 8, 2002
Messages
6,194
If you want the path and the name of the current database, then use:
CurrentDb.Name

If you want just the name of the current database, then use:
Dir(CurrentDb.Name)

Or if you only want the path to the current database, then use:
Left(CurrentDb.Name,Len(CurrentDb.Name)-Len(Dir(CurrentDb.Name)))

HTH
 

dcx693

Registered User.
Local time
Today, 16:38
Joined
Apr 30, 2003
Messages
3,265
If you're using Access 2000+, you can use:
CurrentProject.Name for just the filename
CurrentProject.Path for just the path, or
CurrentProject.FullName for both
 

MikeAngelastro

Registered User.
Local time
Today, 14:38
Joined
Mar 3, 2000
Messages
254
Thanks to all of you. Its amazing how much of the details behind MS's creations are difficult to find. Thanks to forums like this one, we can find out what we need to know.

Thanks again.
 

MikeAngelastro

Registered User.
Local time
Today, 14:38
Joined
Mar 3, 2000
Messages
254
Hi,

Now that I am able to capture the file's name - thanks to you folks - I suddenly realized I don't know how to go the rest of the way.

I created a table with a list of control names that would be disabled if the filename were let's say "progInventory.mde" but, when I started to write the code to iterate through the table, I realized that I don't know any code to set a controls property values when the program only knows the control's name in string format because it came from a table. You can run a report in this way because of the OpenReport method of the DoCmd object uses that report name as a string parameter.

My problem is this:

A control I want to make invisible is btnPost. The program knows this because it is contained in a string field as "btnPost" in a recordset. How do I go from "btnPost" to btnPost.Visible = False?


Thanks,

Mike
 

Keith P

Registered User.
Local time
Today, 21:38
Joined
Oct 11, 2000
Messages
122
If you are referring to the control from within the Form try
me("btnPost").visible = false
 

dcx693

Registered User.
Local time
Today, 16:38
Joined
Apr 30, 2003
Messages
3,265
KeithP is right if you've got the string name of the control. But if btnPost is a string being referred to by a variable, say "ctl", then use Me(ctl).Visible=False. If you're recordset field is, say "ctl" and your recordset variable is "rst", then you can use Me(rst("ctl")).Visible=False. I'm pretty sure that's the right syntax, though I've never used that exact method myself.
 

MikeAngelastro

Registered User.
Local time
Today, 14:38
Joined
Mar 3, 2000
Messages
254
Thanks to both Keith and DCX693,

I think I will find uses for both approaches. I will give them a try and let you know how it goes.

Thanks again,

Mike
 

MikeAngelastro

Registered User.
Local time
Today, 14:38
Joined
Mar 3, 2000
Messages
254
Hi,

I used Keith's approach. It was more comapatible with the data format. But it works quite well.

My job is to customize an Access based Accounting program. Let's say it's called "Actg.mde". When I complete some new functionality, I make a copy called Actg_NEXT.mde and send it to the server. At the server I have a batch file that runs each night. This batch file deletes the old copies of the DB and copies the new one in with the appropriate filenames.

When the users return in the morning, they load the new program and get only the functionality they shoud have. I even created some relevant tables and a form for the business owner to manage the process.

I am actually launching it in the morning, but my testing tells me that it should work well.

Thanks again for your help.

Mike
 

Users who are viewing this thread

Top Bottom