Is there a way to Identify different front ends (same accde name) using VBA, local name or even folder share name? (1 Viewer)

bignose2

Registered User.
Local time
Today, 19:09
Joined
May 2, 2010
Messages
219
Tricky to explain,
I have 4 or 5 front ends connected to a BE on the same LAN.
They have the same name.
I might be over complicating this but ideally would like to be able to identify each front end.
FrontEnds are on C:\Documents etc. etc. not the same location Pc to PC
e.g. pressing a button on ..
FrontEndA will copy a file to D:\MainPC\AccessBackups
FrontEndB will copy a file to D:\OfficePC\Backups

Also stuff like what printer to use.

As FrontEndA & B have the same name, cannot see, in VBA, a way to know which PC & FrontEnd is being used.

Now, I could give them all a different name, have a table with all the information I manually enter, not too keen for some reason.
Although don't do often, I might add another FE PC into the system & perhaps take one out.

Each FE will always have a shared folder on a local drive that I backup & store other data into. I do have this recorded in a table.
My first thoughts were, if I can see what the local share is I could use that but not sure there is a way to find out what the local share/PC is?
As above
\\MainPC\AccessBackups
\\OfficePC\Backups

Any idea's?
I think I might be over engineering this
 

theDBguy

I’m here to help
Staff member
Local time
Today, 11:09
Joined
Oct 29, 2018
Messages
21,474
Try doing a search on "Dev/Test/Live" demo or code.
 

Ranman256

Well-known member
Local time
Today, 14:09
Joined
Apr 9, 2015
Messages
4,337
put a text box on the form with this datasource:
=currentdb.Name
 

bignose2

Registered User.
Local time
Today, 19:09
Joined
May 2, 2010
Messages
219
Thanks, but as I say they are all the same name.
Unless I give all the front ends a different name currentdb.name would all be
e.g. "BookingSystem.accde"



ref. the DBGuy reply
Had a quick google "Try doing a search on "Dev/Test/Live" demo or code."
Is this a whole new DB system?
My DB I huge now with thousands of lines of code.
I know odd this problem has now come up but doing a lot more individual stuff, backups & other things.
 

theDBguy

I’m here to help
Staff member
Local time
Today, 11:09
Joined
Oct 29, 2018
Messages
21,474
ref. the DBGuy reply
Had a quick google "Try doing a search on "Dev/Test/Live" demo or code."
Is this a whole new DB system?
My DB I huge now with thousands of lines of code.
I know odd this problem has now come up but doing a lot more individual stuff, backups & other things.
If you find what I was referring to, you can simplify study it and apply the applicable techniques to your own application.
 

moke123

AWF VIP
Local time
Today, 14:09
Joined
Jan 11, 2013
Messages
3,920
take a look at environ()

https://bettersolutions.com/vba/functions/environ-function.htm

Code:
?environ("userName")
?Environ("ComputerName")

Another option is to place the backup folders in the same folder as the front end and then use
currentproject.path & "\MyBackUpFolderName"

or parse the name out of the CurrentProject.Path
C:\Users\JSmith\Desktop\NewDB\MyDb.accdb
 
Last edited:

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Today, 13:09
Joined
Feb 28, 2001
Messages
27,188
The suggestion by Moke123 is good (computer name from "Environ" function.) If those computers are used by different persons, you could also see who is logged in and have a little table keyed by username to list all the information you need about the given environment.

There is also the possibility that you would use the C drive's serial number to identify which machine your FE is using. Using the file system object, you can use the GetDrive function to create a "drive" object, then look at the drive object's .SerialNumber property.

Code:
Set DrvObj = fso-object.GetDrive( "C:" ) 
strDrvSerNum = DrvObj.SerialNumber

As long as there is nothing "funky" about your system, the C drive's serial number should be unique. Once you know it, you can have a table of known drive serial numbers that would help you look up stuff.
 

Isaac

Lifelong Learner
Local time
Today, 11:09
Joined
Mar 14, 2017
Messages
8,777
Tricky to explain,
I have 4 or 5 front ends connected to a BE on the same LAN.
They have the same name.
I might be over complicating this but ideally would like to be able to identify each front end.
FrontEnds are on C:\Documents etc. etc. not the same location Pc to PC
e.g. pressing a button on ..
FrontEndA will copy a file to D:\MainPC\AccessBackups
FrontEndB will copy a file to D:\OfficePC\Backups

Also stuff like what printer to use.

As FrontEndA & B have the same name, cannot see, in VBA, a way to know which PC & FrontEnd is being used.

Now, I could give them all a different name, have a table with all the information I manually enter, not too keen for some reason.
Although don't do often, I might add another FE PC into the system & perhaps take one out.

Each FE will always have a shared folder on a local drive that I backup & store other data into. I do have this recorded in a table.
My first thoughts were, if I can see what the local share is I could use that but not sure there is a way to find out what the local share/PC is?
As above
\\MainPC\AccessBackups
\\OfficePC\Backups

Any idea's?
I think I might be over engineering this
Aren't the users' logged-in usernames different?
That is the often approach to identifying who/what is what..
Rather than filename which users shouldn't be allowed to change..
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Today, 13:09
Joined
Feb 28, 2001
Messages
27,188
IF the situation is like a shop floor where anyone can use any computer (via domain login) then either the Environ("ComputerName") or the trick of getting the boot drive's serial number would be the two best ways to get the job done.

If every computer is used by one and only one user, then the Environ("Username") or one of Isladogs' articles on getting the network name would be enough.
 

bignose2

Registered User.
Local time
Today, 19:09
Joined
May 2, 2010
Messages
219
Very many thanks to you all

I am sure one of those will give me exactly what I want.
My apologies to RanMan256 as actually, currentdb.Name can give some username infrom from the drive name, not sure 100% of what I wanted but sure would have worked.
The Environ("Username") looks perhaps slightly better for me

Thanks again.
 

gemma-the-husky

Super Moderator
Staff member
Local time
Today, 19:09
Joined
Sep 12, 2006
Messages
15,657
the current database details are

currentproject.path and currentproject.name

if multiple databases have the same name, then you have to use the path to distinguish the name, or alternatively include some agreed naming style as a value within a database settings table- but you won't see that until you open the database.

A different way of doing it is to have a single front end, but multiple back ends, then allow the user to select the target database. Most multi-company accounting systems works like that.

eg, with Sage, the user knows that
company.001 is Acme Sales
company.002 is Acme Special Events
company.003 is Acme Construction
etc.
 

Users who are viewing this thread

Top Bottom