Create DB and make it hidden (1 Viewer)

speakers_86

Registered User.
Local time
Today, 16:34
Joined
May 17, 2007
Messages
1,919
Code:
Public Function InstallFE()
  On Error GoTo ProcError
 
  Dim strSourceFile As String
  Dim strDestFile As String
  Dim strAccessExePath As String
  Dim lngResult As Long
Dim WSHShell As Object
Set WSHShell = CreateObject("WScript.Shell")
Dim MyShortcut As Object
Dim DesktopPath As String
' Read desktop path using WshSpecialFolders object
DesktopPath = WSHShell.SpecialFolders("Desktop")
  'Create the source's path and file name.
  strSourceFile = CurrentProject.FullName 'strFEMasterPath '"\\server\share\YourFEDatabase.mde"
  strDestFile = DesktopPath & "\" & CurrentProject.Name 'CurrentProject.FullName
  'Determine path of current Access executable.
  strAccessExePath = SysCmd(acSysCmdAccessDir) & "MSAccess.exe "
  If Dir(strSourceFile) = "" Then 'Something is wrong and
                                             ' the file is not there.
     MsgBox "The file:" & vbCrLf & Chr(34) & strSourceFile & _
       Chr(34) & vbCrLf & vbCrLf & _
       "is not a valid file name. Please see your Administrator.", vbCritical, "Error Updating To New Version..."
       GoTo ExitProc
  Else 'copy the new version of app over the existing one.
     lngResult = apiCopyFile(strSourceFile, strDestFile, False)
  End If
  'Modify strDestFile slightly so that it can be used
  ' with the Shell function.
  strDestFile = """" & strDestFile & """"
  MsgBox "Application Updated. Please wait while the application" & _
     " restarts.", vbInformation, "Update Successful"
  'Load new version, then close old one.
  Shell strAccessExePath & strDestFile & "", vbMaximizedFocus
  DoCmd.Quit
ExitProc:
Exit Function
ProcError:
  MsgBox "Error " & Err.Number & ": " & Err.Description, , _
     "Error in UpdateFEVersion event procedure..."
  Resume ExitProc
End Function


How can I make the file that this code creates hidden? I thought there was a character I could just put in front of the file name to signify it should be hidden, and I could have sworn it was the $, but that did nothing.
 

vbaInet

AWF VIP
Local time
Today, 21:34
Joined
Jan 22, 2010
Messages
26,374
Are you sure you want to do this speakers? I don't know what the implications are w.r.t programmatically opening the db or the like. You might want to investigate this.

I would opt for creating the db in a secure location setup for you by your Sys Admins (at MOD ;) )

In any case, look for the command that allows you to do this in command prompt and run that command via Shell or ShellExecute. If you are having problems finding it, ask in the Windows section of the forum.
 

Lightwave

Ad astra
Local time
Today, 21:34
Joined
Sep 27, 2004
Messages
1,521
Just a thought maybe you could hide the directory and then place all files in the directory not exactly what you asked for but might be useful.

EDIT Actually looks like your putting files in the directory desktop so that might not work.
 

speakers_86

Registered User.
Local time
Today, 16:34
Joined
May 17, 2007
Messages
1,919
Yeah, I was wondering how good of an idea this is too. I figure it it might lead to corruption, given that it writes over itself. But I did test it out, and it works brilliantly. If it is a concern, perhaps I could do this from a secondary db, like some of the other tools out there. What do you think?

@Lightwave, that is probably better, in case I ever have more than one file to hide. But could you tell me how to make that file hidden? I don't believe I have ever worked with windows objects like this before, so it's new to me.

edit - It does not have to be the whole desktop! I could make another folder.

Maybe I will keep looking for a fe updater. Probably tomorrow though, as I am still pretty burnt out. I couldn't get Pete's software working, and Bob Larson's tool I looked at, but didn't go through all the steps yet. FYI, what I have is a local table in each fe, and a table in the be. Each contains a version number. If the fe version is less than the be version, the system should automatically update. If you know of good tools for this, other than Pete's or Bob Larson's, feel fee to give your input!
 
Last edited:

Lightwave

Ad astra
Local time
Today, 21:34
Joined
Sep 27, 2004
Messages
1,521
Just looked this up - this is XP I would suspect this can be done in Windows 7 but you might have to look it up

To turn on the hidden attribute right click on the folder icon, select Properties, then the General Tab and check the Hidden box.

The folder should disappear from My Documents. If it doesn't then you have Windows Explorer configured to display hidden files.

To change this, select Tools / Folder options / View then check the "Do not show hidden files and folders" box. Now the test folder should disappear. To make it re-appear select the "Show hidden files and folders" option.

This is from

http://www.techsupportalert.com/how_to_hide_a_windows_folder.htm
 

vbaInet

AWF VIP
Local time
Today, 21:34
Joined
Jan 22, 2010
Messages
26,374
I would go with the Folder option to be honest!

It's an attrib thing in command prompt.
 

speakers_86

Registered User.
Local time
Today, 16:34
Joined
May 17, 2007
Messages
1,919
vbaInet, what were your reservations on this code?
 

vbaInet

AWF VIP
Local time
Today, 21:34
Joined
Jan 22, 2010
Messages
26,374
I have no qualms about your code. The only thing I would do is add an extra condition to update the file if the Modified Date of the new file is different from the Modified Date of the current file.

Besides that, there's a tool by Tony Toews for updating FEs. You could look into that. I understand it's quite a good tool.
 

speakers_86

Registered User.
Local time
Today, 16:34
Joined
May 17, 2007
Messages
1,919
I will check that out, thanks. so you don't think corruption might be more likely with this? Even with me replacing a file from INSIDE the file I am replacing?

edit-I have seen that before. I am working on classified machines though, so I don't think I can install programs, especially ones I did not make.
 

vbaInet

AWF VIP
Local time
Today, 21:34
Joined
Jan 22, 2010
Messages
26,374
I don't know! All I can say is ensure that the user is not logged into the db and the FE is not open before attempting to replace.
 

NigelShaw

Registered User.
Local time
Today, 21:34
Joined
Jan 11, 2008
Messages
1,573
Hey,

couldnt you just have a separate db holding this code that fires up when the main application opens and then stays open to create the new one and close the old one? you could hide the icon from the taskbar or minimize the application itself on startup?

just a thought :)


Nidge
 

speakers_86

Registered User.
Local time
Today, 16:34
Joined
May 17, 2007
Messages
1,919
I was about to give up on making the folder hidden, but then i found this, so I'll give that a try. As for the code, I'll see about making it seperate from my fe.
 

vbaInet

AWF VIP
Local time
Today, 21:34
Joined
Jan 22, 2010
Messages
26,374
That was mentioned 6 posts away all you needed to do was investigate the method. I mentioned using the attrib command in command prompt but it requires a switch or option (which is what you were required to investigate). There's Shell in VBA so you give it the command and the option and it's done.
 

Users who are viewing this thread

Top Bottom