Updating the front end on local server (1 Viewer)

Gasman

Enthusiastic Amateur
Local time
Today, 07:34
Joined
Sep 21, 2011
Messages
14,050
It has been a while since I used Bob's utility, but as it is something that just needs to be carried out once, why not just follow the simple instructions below.? How hard is it to make a simple link *once*?
Admittedly I did create a new form to make the version change easier and also had a memo field to log the changes as mine was a work in progress. :)

1593496883933.png
 

oxicottin

Learning by pecking away....
Local time
Today, 03:34
Joined
Jun 26, 2007
Messages
851
It has been a while since I used Bob's utility, but as it is something that just needs to be carried out once, why not just follow the simple instructions below.? How hard is it to make a simple link *once*?

I know it is just once BUT I like to learn new things 😊
 

Gasman

Enthusiastic Amateur
Local time
Today, 07:34
Joined
Sep 21, 2011
Messages
14,050
I know it is just once BUT I like to learn new things 😊
Well in that case I expect the strBEFile would be the value of the control on his form where you enter the BE file path?
 

Gasman

Enthusiastic Amateur
Local time
Today, 07:34
Joined
Sep 21, 2011
Messages
14,050
I have just split my test DB and installed the tables.
You are running that code you posted from your DB aren't you.?
I just ran that code with a hardcoded BE file in the immediate window and have the table linked no problem.?
1593504002147.png
 

MattBaldry

Self Taught, Learn from the Forums
Local time
Today, 07:34
Joined
Feb 5, 2019
Messages
292
This is the batch file used for normal LAN operation.
Code:
md c:\DwgLog
del c:\DwgLog\DrawingLog.accdb
copy "\\BSCCTIMBERLINE1\Timberline Office\AccessApps\Data\CommonFE\DrawingLog.accdb" c:\DwgLog
c:\DwgLog\DrawingLog.accdb
This is the file used for Citrix or RDP oeration.
Code:
md %USERPROFILE%\DwgLog
del %USERPROFILE%\DwgLog\DrawingLog.accdb
copy "\\BSCCTIMBERLINE1\Timberline Office\AccessApps\Data\CommonFE\DrawingLog.accdb" %USERPROFILE%\DwgLog
%USERPROFILE%\DwgLog\DrawingLog.accdb

The difference is that you can hard-code the target locations if you are running on a standard LAN but with the other environments, you need to use the users personal directory as the target location.

As you can see, there is no error checking code in the script. None is actually needed. If the directory already exists, the md doesn't raise an error and for the del, if the file doesn't exist, that also doesn't raise an error. I've seen scripts that go on for pages but this is all I've ever needed.

Thanks Pat
 

oxicottin

Learning by pecking away....
Local time
Today, 03:34
Joined
Jun 26, 2007
Messages
851
Yes I am trying the code I posted and it does link the "tbl-version_fe_master" BUT it links it to the updater and not the intended FE
 

Isaac

Lifelong Learner
Local time
Today, 00:34
Joined
Mar 14, 2017
Messages
8,738
Then one of these must be wrong
strBEFile = Me.txtBackEnd
strFEFile = Me.txtFEMaster

But I'm with Gasman. Just make the darn link and sail away 🚤
 

Gasman

Enthusiastic Amateur
Local time
Today, 07:34
Joined
Sep 21, 2011
Messages
14,050
Then one of these must be wrong
strBEFile = Me.txtBackEnd
strFEFile = Me.txtFEMaster

But I'm with Gasman. Just make the darn link and sail away 🚤
@pisorsisaac@gmail.co
That code is in Bobs updater, where he transfers his tables into one's FE & BE?
Obviously for it to work as the o/p wishes the code to create the link should be in his DB and have the correct values?
I do not think that is the case here.?

@oxicottin if you must persist with this, I would test for the table name in tabledefs and if not found link, but put that code in your DB.
 

Isaac

Lifelong Learner
Local time
Today, 00:34
Joined
Mar 14, 2017
Messages
8,738
Yeah but the controls txtBackEnd have to be holding the correct values, which I think may depend on the person using it.
I dunno, really..
 

MattBaldry

Self Taught, Learn from the Forums
Local time
Today, 07:34
Joined
Feb 5, 2019
Messages
292
This is the batch file used for normal LAN operation.
Code:
md c:\DwgLog
del c:\DwgLog\DrawingLog.accdb
copy "\\BSCCTIMBERLINE1\Timberline Office\AccessApps\Data\CommonFE\DrawingLog.accdb" c:\DwgLog
c:\DwgLog\DrawingLog.accdb
This is the file used for Citrix or RDP oeration.
Code:
md %USERPROFILE%\DwgLog
del %USERPROFILE%\DwgLog\DrawingLog.accdb
copy "\\BSCCTIMBERLINE1\Timberline Office\AccessApps\Data\CommonFE\DrawingLog.accdb" %USERPROFILE%\DwgLog
%USERPROFILE%\DwgLog\DrawingLog.accdb

The difference is that you can hard-code the target locations if you are running on a standard LAN but with the other environments, you need to use the users personal directory as the target location.

As you can see, there is no error checking code in the script. None is actually needed. If the directory already exists, the md doesn't raise an error and for the del, if the file doesn't exist, that also doesn't raise an error. I've seen scripts that go on for pages but this is all I've ever needed.

Hi Pat,

Love this code, works perfect, just not quite for me. Would you know how I would use this if my folder/file name have spaces in it? I have looked around the web and seen that I should have "" and then the file/folder name in quotes, but it is not quite working for me.

~Matt
 

Gasman

Enthusiastic Amateur
Local time
Today, 07:34
Joined
Sep 21, 2011
Messages
14,050
PMFJI
I was able to copy a file from a folder to one with spaces in it?:unsure:
Code:
MOZ_PLUGIN_PATH=C:\PROGRAM FILES\FOXIT SOFTWARE\FOXIT READER\plugins\
Code:
copy test.txt "%MOZ_PLUGIN_PATH%test.txt
 

MattBaldry

Self Taught, Learn from the Forums
Local time
Today, 07:34
Joined
Feb 5, 2019
Messages
292
PMFJI
I was able to copy a file from a folder to one with spaces in it?:unsure:
Code:
MOZ_PLUGIN_PATH=C:\PROGRAM FILES\FOXIT SOFTWARE\FOXIT READER\plugins\
Code:
copy test.txt "%MOZ_PLUGIN_PATH%test.txt
Cannot even explain how, but today the same code works fine. All sorted.

~Matt
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 03:34
Joined
Feb 19, 2002
Messages
42,981
You're welcome. I NEVER use embedded spaces or other special characters so I never run into this type of problem. However, you should be able to enclose the path names in double quotes to get around the offending characters.

Remember, programming languages do NOT allow spaces in their variable names and many also don't allow special characters. So, you are always at jeopardy when working with paths that contain embedded spaces and/or special characters when you are manipulating them via code.
 

oxicottin

Learning by pecking away....
Local time
Today, 03:34
Joined
Jun 26, 2007
Messages
851
I got it to update my links...

Code:
 Private Sub Link()
    Dim dbFE As DAO.Database
    Dim dbBE As DAO.Database
    Dim tdf As TableDef
    Dim tdf1 As TableDef
    Dim strFEFile As String
    Dim strBEFile As String
    Dim strTblName As String
    
    strBEFile = Me.txtBackEnd
    strFEFile = Me.txtFEMaster
  
    Set dbFE = DBEngine.Workspaces(0).OpenDatabase(strFEFile)
    Set dbBE = DBEngine.Workspaces(0).OpenDatabase(strBEFile)
    
    On Error Resume Next
    For Each tdf1 In dbBE.TableDefs
        strTblName = tdf1.Name
        If Left(strTblName, 4) <> "msys" Then
            dbFE.TableDefs.Delete strTblName
            Set tdf = dbFE.CreateTableDef(strTblName)
            tdf.Connect = ";DATABASE=" & strBEFile
            tdf.SourceTableName = strTblName
            dbFE.TableDefs.Append tdf
        End If
    Next tdf1
    
    Set dbBE = Nothing
    Set dbFE = Nothing
    
     MsgBox "tbl-version_fe_master was successfully linked!", vbInformation, "Link Complete"
    
End Sub
 

oxicottin

Learning by pecking away....
Local time
Today, 03:34
Joined
Jun 26, 2007
Messages
851
Im having an issue updating when I change versions though. I create my .accde and put it in my folder ect then if I change the version number on my .accdb and replace the existing .accde and open my old version it says my version is old like it should and it creates the .cmd file and updates to the new version BUT doesnt delete the .cmd file and reopen the database. If I click on the FE I was trying to update it opens and then deletes the .cmd file. I looked at the .cmd file and the paths are correct. In Bobs origional database I got rid of a lot and built off that.

Second question is for Gasman, I added a form that I wanted to make this more automated and im wanting to add a button to the form that will create a .accde from within my FE Master to make it more automated. I found a post from years ago that you asked the same question and solved it but never posted the complete code. I also attached what I have so far...

HERE is the post/thread....

Thanks,
 

Eljefegeneo

Still trying to learn
Local time
Today, 00:34
Joined
Jan 10, 2011
Messages
904
The batch file update is the best way to handle this. I put a copy of the new front end on the server, link it to the back end on the server and then send everyone who will use this DB and email message to "Update Your Front End". They all have a batch file on their desktop that will update their front end by copying this new front end to their desktop and open the program. As a precaution I added a line of code to save their most recent front end to a folder on their desktop so that if something goes amiss, they will still have a copy of their old front end. This worked for more than 8 years and some of my "users" can do things to really mess up their front ends. This method has never failed me.

Listen to Pat, keep it simple!
 

Gasman

Enthusiastic Amateur
Local time
Today, 07:34
Joined
Sep 21, 2011
Messages
14,050
Im having an issue updating when I change versions though. I create my .accde and put it in my folder ect then if I change the version number on my .accdb and replace the existing .accde and open my old version it says my version is old like it should and it creates the .cmd file and updates to the new version BUT doesnt delete the .cmd file and reopen the database. If I click on the FE I was trying to update it opens and then deletes the .cmd file. I looked at the .cmd file and the paths are correct. In Bobs origional database I got rid of a lot and built off that.

Second question is for Gasman, I added a form that I wanted to make this more automated and im wanting to add a button to the form that will create a .accde from within my FE Master to make it more automated. I found a post from years ago that you asked the same question and solved it but never posted the complete code. I also attached what I have so far...

HERE is the post/thread....

Thanks,
That is probably where your problem lies. ? :(
The most I did to Bob's code was make the check <= instead of Not =.

As for making the accde, I'll have to look on another computer.

Perhaps Pat's method is a better option for you after all?
I just have a little problem with copying something 100 or 1000 times when it is only needed once or twice, but that is just me. :D
 

Gasman

Enthusiastic Amateur
Local time
Today, 07:34
Joined
Sep 21, 2011
Messages
14,050
OK, found the code in another DB.
I *think* you have all you need in the attached.
If not come back with specific missing items and I will go looking.

This is a DB that I probably last touched back in 2017 as far as development goes. :(

HTH
 

Attachments

  • accde.accdb
    396 KB · Views: 150

Gasman

Enthusiastic Amateur
Local time
Today, 07:34
Joined
Sep 21, 2011
Messages
14,050
No essential for creating the accde, but here is that routine.

Code:
Sub CreateBackup(Optional strDBType As String)
    Dim strDBpath As String, ext As String, tmp As String
    Dim strPath As String, strBackupPath As String, strDB As String
    
    
    'tmp = CurrentDb.Name    'or maybe this should be the name of your BE
    'strDBType = "FE"
    strDBpath = GetAccessBE_PathFilename("tblUser")
    strPath = Left(strDBpath, InStrRev(strDBpath, "\"))
    strBackupPath = strPath & "Backup\"
    
    'Will nor backup front and back end database
    If strDBType = "FE" Then
        strDBpath = CurrentDb.Name
    End If
    strDB = Right(strDBpath, Len(strDBpath) - InStrRev(strDBpath, "\"))
    
    With CreateObject("Scripting.FileSystemObject")
        'ext = "." & .GetExtensionName(tmp)
        tmp = strBackupPath & Format(Now(), "yyyymmdd_hhnnss") & "_" & strDB
        .CopyFile strDBpath, tmp
    End With
    MsgBox strDBType & " Database saved as " & tmp
    
    
End Sub
 

oxicottin

Learning by pecking away....
Local time
Today, 03:34
Joined
Jun 26, 2007
Messages
851
Ye sorry about that, i deleted my post after i realized it had nothing to do with it. I got that working and is being placed in my distribution folder... Works like a charm 👍 thanks!
 

Users who are viewing this thread

Top Bottom