Opening File on StartUp

  • Thread starter Thread starter Nylex
  • Start date Start date
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
 
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
 
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.
 
Tks - I used this suggestion and it worked fine - havent tried the other
suggestion as this one works
 
Douglas this post helped me, just wanted you to know as it didn't look like
you were going to get anything from Nylex.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top