VBA Code Wiped

dichotomous

Registered User.
Local time
Today, 11:29
Joined
Oct 19, 2012
Messages
62
Hello

I have a front end and back end on a terminal server.

The front end was opened the other day by an administrator (direct from its location on the terminal server).

He found he couldn't log in. The issue was that all the VB coding was gone.

This has happened twice now.

There was a saved copy of the Front end, so, it was restored. But, I would like to know how this is occurring.

This particular user insists on using a short cut, rather than a copy on his desk top, which is particularly annoying - and I have no control over his behaviour.

I don't know where to even start looking to get to the bottom of this problem.

The other users who have FE copies on their desk tops have no issues.

:eek:
 
Tell the user they are causing the problem and that you won't be fixing it again.
 
not sure how the user is removing all code, but you can put something in the opening code which checks the currentproject.path - if it doesn't start with 'c:\' then quit the application - perhaps with a 'tut tut' message.

Also, use a .accde rather than .accdb
 
and I have no control over his behaviour.

Yes, actually you do - if it is a split FE/BE and if the "shared" FE file that everyone should copy is in the same general path as the "shared" BE that the FE references.

In your opening form (if you use one), in the Form_Open event, parse out CurrentDB.Name, which will be the path to the current FE. Just for snorts & giggles, you could also create an otherwise unused table in the FE file, then look at the table's CONNECT property. If the FE table matches the location of the FE database as a whole but DOES NOT match the location of the BE file, let it open. Otherwise, cancel the Form_Open or do an Application.Quit on it.
 
This particular user insists on using a short cut, rather than a copy on his desk top, which is particularly annoying - and I have no control over his behaviour.
What is this short cut to?

  1. The frontend copy on his computer?
  2. A frontend copy on the server?
  3. The backend?

I wouldn't think #1 would cause this problem.
 
Hi,

My clients have on there desktop an App, that at execution this code:
Code:
Private Sub copyAndOpenFile(Folder as String, FileName As String)    

    FileCopy Folder & "\" & FileName, "C:\Temp\" & FileName 
    dOpenFile.OpenFile "C:\Temp\" & FileName
End Sub
Very simple code to achieve your needs. Be sure to add this code to a module object, and name it dOpenFile. I've found this module on the web (perhaps in this forum...):
Code:
Option Compare Database
Option Explicit

Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long

Public Function OpenFile(sFileName As String)
    OpenFile = ShellExecute(Application.hWndAccessApp, "Open", sFileName, "", "C:\", 1)

End Function
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Public Function TestOpeningFile()
On Error GoTo Err_TestOpeningFile

    OpenFile "C:\Windows\Win.ini"
    
Exit_TestOpeningFile:
    Exit Function

Err_TestOpeningFile:
    MsgBox Err.Number & " - " & Err.Description
    Resume Exit_TestOpeningFile
    
End Function
 
Don't assume that code removal is the user's fault. I have a problem with the SQL text disappearing from queries when I use it to generate an e-mail. I had to write a VBA procedure to restore the wiped text.
 

Users who are viewing this thread

Back
Top Bottom