Opening File on StartUp

N

Nylex

When the Database first starts up I need to open a file and check what to do
the file name that I have to open is "MN.TXT"

if the name in it is "Master" I want to run macro "Setup" - any other name
in the file and it is to run macro "Update"

I have trial run my macro on all the computers on the network and everything
works
but I have to tell it what Macro to run - am worried that the staff will
forget to run the proper macro or not run one at all

Would appreciate any advice
 
D

Douglas J. Steele

Are you saying that the content of MN.TXT will contain something?

Dim intFile As Integer
Dim strFile As String
Dim strBuffer As String

strFile = "E:\Folder\MN.TXT"
intFile = FreeFile
If Len(Dir(strFile)) > 0 Then
Open strFile For Input As #intFile
If Not EOF(intFile)
Line Input #intFile, strBuffer
End If
Close #intFile
End If

Select Case strBuffer
Case "Master"
' Put your code to run macro Setup
Case Else
' Put your code to run macro Update
End Select
 
D

Douglas J. Steele

Incidentally, there are simpler ways of accomplishing what you're trying to
do.

You can create a shortcut that passes a start up command to Access. The
shortcut MUST include the full-path to msaccess.exe, since the startup
command you're passing is a parameter for Access, not for the mdb file:

"C:\Program Files\Microsoft Office\Office\MSAccess.exe"
"E:\Folder\SubFolder\File.mdb" /cmd Master

Now, in your application you use the Command function to see what was
passed.
 
N

Nylex

Tks - I used this suggestion and it worked fine - havent tried the other
suggestion as this one works
 
S

scratchtrax

Douglas this post helped me, just wanted you to know as it didn't look like
you were going to get anything from Nylex.
 
Top