Disable Startup Programmatically

Is it possible to Programmatically open an Access database while bypassing 
the startup?

Basically I need the VBA equivilent of holding the Shift Key. 

I can definitely get into the nuts and bolts of the issue further but the 
general overview is that I am writing a version control module. It checks to 
see if there is a new version avaliable and the path to the newest version 
from an external Db on startup. If obsolete it creates and runs  an 
executable that saves the obsolete db as a new name then copies the new 
version into the same folder. It then opens the new version and runs a sub 
(within the new version) that copies all applicable tables from old Db to 
new. 

The whole process works fine except when the new db opens I don't want it to 
open the startup forms as I want this version control to work on all 
databases regurdless on what happens at startup. 



0
Utf
2/16/2010 6:08:01 PM
access.modulesdaovba 1670 articles. 0 followers. Follow

1 Replies
880 Views

Similar Articles

[PageSpeed] 42

See code below:


Option Compare Database
Option Explicit
Public Const MACRONAME = "Trial Access Database"
Public Const MACROVER = "1.000"
Public Const MACRODATE = "2/28/2010"
Public Const MACROBY = "VirtualIT"
Public Const VPATH = "ServerName"
Public Const VDRIVE = "\FolderName\"
Public Const VERSIONDB = "VersionControl.mdb"

Public Sub CheckVersion()
   Dim strSQL As String
   Dim cnnConn As New ADODB.Connection
   Dim rstVersion As New ADODB.Recordset
   Dim OldFile As String
   Dim NewFile As String
   Dim CurrPath As String
   Dim MacroFile As String
   Dim fs As Object
   
   '//Connects to Version Control Database
   With cnnConn
      .ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0"
      .Open "\\" & VPATH & VDRIVE & VERSIONDB
   End With
   
   '//Retrieves Recordset matching the constant MACRONAME
   With rstVersion
      .CursorType = adOpenForwardOnly
      .LockType = adLockReadOnly
      .Open "SELECT * FROM tblVersion WHERE MacroName = '" & MACRONAME & 
"'", cnnConn
      If .EOF Then
         MsgBox ("Macro does not exist in database, please email VirtualIT 
for assistance.")
         Exit Sub
      Else
         
         '//Compares the constant MACROVER to the corresponding Version 
Number saved in
            'the Version control Db
         If .Fields("VersionNumber") <> MACROVER Then
            
            '//Informs user that there is a newer version available
            MsgBox ("A new version of this macro is available." & vbNewLine 
& vbNewLine & _
            "Version: " & .Fields("VersionNumber") & "  Released: " & 
..Fields("ReleaseDate") & "." & _
            vbNewLine & vbNewLine & "Please click OK to continue update.")
            
            '//Saves the obsolete Db as Filename_old_MMDDYYYY
            Set fs = CreateObject("Scripting.FileSystemObject")
            MacroFile = .Fields("MacroPath") & .Fields("MacroFileName")
            OldFile = CurrentProject.Name
            CurrPath = CurrentProject.path & "\"
            NewFile = Mid(OldFile, 1, Len(OldFile) - 4) & "_old_" & 
Format(Date, "mmddyyyy") & ".mdb"
            fs.copyfile CurrPath & OldFile, CurrPath & NewFile
            
            
            Call CreateBat(MacroFile, CurrPath & OldFile)
            Call CreateVbs(CurrPath, OldFile, NewFile)
            
            MsgBox ("A copy is saved to " & CurrPath & NewFile & vbNewLine & 
vbNewLine & _
            "Please allow update to finish and new version will open.")
            
            
            Shell "C:\Temp\CTSGUpdate.bat", vbMaximizedFocus
            DoCmd.Quit
         End If
      End If
      .Close
   End With
End Sub

Public Sub CreateBat(MacroFile As String, OldFile As String)
   Dim FileNum%
   FileNum = FreeFile()
   Open "C:\Temp\Update.bat" For Output As #FileNum
   Print #FileNum, "ECHO Please wait for update to complete..."
   Print #FileNum, "@ECHO OFF"
   Print #FileNum, "ping -n 5 127.0.0.1 >nul"
   Print #FileNum, "ECHO ON"
   
   '//Copy current version of Db to obsolete version file path
   Print #FileNum, "XCopy " & Chr$(34) & MacroFile & Chr$(34) & " " & 
Chr$(34) & OldFile & Chr$(34) & " /Y"
   
   '//Run C:\Temp\Update.vbs
   Print #FileNum, Chr$(34) & "C:\Temp\Update.vbs" & Chr$(34)
   Close #FileNum
End Sub

Public Sub CreateVbs(CurrPath As String, OldFile As String, NewFile As String)
   Dim FileNum%
   FileNum = FreeFile()
   Open "C:\Temp\Update.vbs" For Output As #FileNum
   Print #FileNum, "Set appAccess = CreateObject(" & Chr$(34) & 
"Access.Application" & Chr$(34) & ")"
   
   '//Sets Access security
   Print #FileNum, "appAccess.AutomationSecurity = 1"
   

 THIS IS WHERE SOMETHING NEEDS TO BE ADDED SO THAT NO EVENTS RUN UNTIL AFTER 
THE TABLES HAVE BEEN UPDATED   

'//Opens the current version of the database
   Print #FileNum, "appAccess.OpenCurrentDatabase (" & """" & CurrPath & 
OldFile & """" & ")"
   
   '//Runs Update subroutine from new Db
   Print #FileNum, "appAccess.Run " & Chr$(34) & "Update" & Chr$(34) & ", " 
& Chr$(34) & CurrPath & Chr$(34) & ", " & Chr$(34) & NewFile; Chr$(34)
   
   Close #FileNum
End Sub
Private Const TABLES_TO_UPDATE As String = "tbl_test1,tbl_test2,tbl_test3,"



Sub Update(OldPath As String, OldFile As String)
'//Copies all tables from old Db to new db
    
DoCmd.SetWarnings False
    
   Dim lngStartChr As Long
   Dim strUpdateTaleList As String
   Dim strUpdateTableName As String
    
    lngStartChr = 1
    strUpdateTaleList = Trim(TABLES_TO_UPDATE)
    If Right(Trim(strUpdateTaleList), 1) <> "," Then strUpdateTaleList = 
strUpdateTaleList & ","
    Do Until InStr(lngStartChr, strUpdateTaleList, ",") < 1
        strUpdateTableName = Trim(Mid(Trim(strUpdateTaleList), lngStartChr, 
InStr(lngStartChr, strUpdateTaleList, ",") - lngStartChr))
        If Trim(strUpdateTableName) <> "" Then
            DoCmd.RunSQL "SELECT * INTO " & Trim(strUpdateTableName) & " 
FROM " & Trim(strUpdateTableName) & " IN '" & OldPath & OldFile & "'"
        End If
        lngStartChr = InStr(lngStartChr, strUpdateTaleList, ",") + 1
    Loop
    


DoCmd.SetWarnings True
DoCmd.OpenForm ("frm_Start") '//Now open the form that should open on Startup
   
   MsgBox ("Macro updated to version " & MACROVER & ".  If you are not 
expecting this update, please contact VirtualIT immediately.")
End Sub



0
Utf
2/16/2010 10:07:01 PM
Reply:

Similar Artilces:

converting access97 MDB to access2000 MDB, programmatically
Hello, I need to convert an Access97 MDB-database to an Access2000 database. It's no problem using the conversion function of Access2000 itself. However, I'm looking for a way to do this programmatically (C++, MFC etc), i.e. I want to write a small tool that converts the databases of our customers. Upon searching the net and various newsgroups I was not able to find any information about this. Any help would be appreciated & thanks for you time, Steve To be perfectly honest, I wouldn't trust an automated conversion anyhow. You're still going to need to test that it wo...

How can you disable the "It's 12:00 a.m. Would you like the user date to change to..." prompt?
I need to turn the "It's 12:00 a.m. Would you like the user date to change to..." off. Is there a configuration or .ini setting, VBA trick, etc. for disabling this prompt so that when a GP v9 client is running at 12:00 a.m. the user is not presented with this message? Thanks Try the following. If you are using Microsoft Dynamics GP 9.0, add the following line above the "[Install]" section of the Dex.ini file. SuppressChangeDateDialog=TRUE Thanks, rc "MichaelJ" wrote: > I need to turn the "It's 12:00 a.m. Would you like the user date to &g...

Programmatically adding function to copy all incoming mail to public folder (based on sender domain)
Hi all. I would like to be able to (from any client) execute a script (vbs, exe, whatever) that creates a public folder. That's should be pretty easy. The tricky part is that I want the same script to create a rule (?) on the Exchange server that copies all incoming mail from a specific sender domain to that new public folder. Hmm... Let us assume that I have the sufficient credentials for this action hardcoded in the script.. does anyone have a good idea how to do that. I am creating an interface in our ERP software that should be able to see mail correspondance horizontically accross ...

Disable autoarchive
Hello, I would like to disable Auto-Archive at my office for all my Outlook 2003 running PC's. I see in AD the option for "Auto Archive Settings" I currently have it as disabled. Will this prevent users from accessing autoarchive settings, or will it disable autoarchive altogether? Thank you, Mike Chavez "Mike Chavez" <mikec@realtimeca.com> wrote in message news:%23GU8Z% > I would like to disable Auto-Archive at my office for all my Outlook 2003 > running PC's. > > Thank you, Use Outlook Profiler to set most options for Outlook Profiler ...

Disable Right Click on AxWebBrowser
Hi How can I disable mouse right click on the AxWebBrowser component? Regards, Mystique I want to know it, too. Anyone give help. Thanks. Jason "Mystique" wrote: > Hi > How can I disable mouse right click on the AxWebBrowser component? > > Regards, > Mystique > > > ...

Excel Hang unless I disable my LAN
Hi there, I am having problem to open my excel files. Each time I open a file, it will take 10 minutes to open a small file. However, I do noticed that there is alot of activities outgoing in my LAN connection status. If I disable my LAN connection. Then I have no problem open my excel files. I did everything all I can like update my Norton antivirus, perform scanning, update my excel through microsoft. Please help Are there any "broken" network links, for example, mapped drives to computers that are switched off or no longer on the LAN. I think Windows/Excel will try ...

Disable File Open Command On Excel Viewer 2003
Hi, We are creating a web kiosk for our company and have installed the excel viewer for viewinf excel documents on the internet. Problem is the file -> open menu is there and allows browsing to the C:\ drive of the kiosk. From the window that appears they can delete files etc. I would like to know if anyone knows how to get rid of File -> Open on the menu. We have tried the EXCEL11.adm file and setting group policies, but this only applies for the full version of excel. Please help!! I'm not too familiar with the Excel viewer, but ifi it supports VBA then the following line w...

I disabled an user, and then re-enable this user later on. But that user cannot access her Outlook Exchange mail box, and...
....when I sent her a test e-mail, I got this kind of bounce back message: Your message did not reach some or all of the intended recipients. Subject: test Sent: 3/29/2005 4:16 PM The following recipient(s) could not be reached: This Useron 3/29/2005 4:16 PM The message reached the recipient's e-mail system, but delivery was refused. Attempt to resend the message. If it still fails, contact your system administrator. <mailserver.mycompany.net #5.2.1> Here are the servers info: Domain Controller: Windows Server 2003 Exchange Server:...

disabling visibility of calendar
Hello, My chief works on 2 different Exchange organisations (5.5 and 2000/2003). He only uses the calendar in the 2003 organization. Problem is that people from 5.5. organization checks his calendar for availability. How can we hide his "5.5" calendar from being visible to other users? Thanks for any hints, Rolf Utrecht, Netherlands ...

Disable sending out meeting notice
Is there a way to create a meeting in Outlook with Attendees assigned and not have a meeting notice emailed? I use Outlook for my own personal organization and like the fact that I can attach contacts to appointments (i.e. so I can Journal contact information). However, as I recently discovered, they are getting an meeting notice email! Is there a way to disable this while still getting the benefit of Journaling contact information? Thank in advance, Bryan Jones ...

New Message Spelling Check Disabled
Outlook 2003 with Word 2003 as the email editor In the main Outlook window, in Tools > Options > Spelling tab > the box "Always check spelling before sending" is checked. In Word, in Tools > Options > Spelling and Grammar tab > the box "Check spelling as you type" is checked. Every time I start a new message Spelling Check is disabled because Tools > Language > Set Language > the box "Do not check spelling and grammar" is checked. Before I compose an email, I always un-check the box to get Spelling Check to work, but how can I g...

Is there any way to Create a self-extracted file programmatically ?
Hi,guys!I need to create a self-extracted cabinet file with my app,but i don't know how to achieve this.I found ms cabinet sdk,but it dosen't mention the self-extracted cabinet.And i know IEpress can create a self-extracted cabinet file,but i want to write my app as IExpress. Is there any way i can achieve this ? Thank you advance! There is a cabarc.exe for creating cabinet file along with platform sdk. There is also a cabinet sdk available here:- http://download.microsoft.com/download/platformsdk/cab/2.0/w98nt42kmexp/en-us/Cabsdk.exe -- Vipin Aravind Microsoft MVP "how...

Startup
Hello My Excel VBA is sometimes used by other people, and they ara "abusing" my codes by using toolbar commands. I want to make Excel VBA and to hide / disable all toolbars and any other Excel command. I want that only my buttons can be used. Beforehand thanking for any help,7 Sb. I have a few examples on this page and also a example workbook that you can download http://www.rondebruin.nl/menuid.htm -- Regards Ron de Bruin http://www.rondebruin.nl/tips.htm "Sb" <Boro@hi.t-com.hr> wrote in message news:%23I1hvOrgIHA.6084@TK2MSFTNGP06.phx.gbl... > He...

Startup .mny file
Where does money keep track of the .mny file it starts with? If I have 2 different .mny files, how does money know which file to open up. Thanks, Richard "Richard" <rgoldste@earthlink.net> wrote in message news:6h9cm1dkhu6i5ufiav3f5eo24g9bs6leju@4ax.com... > Where does money keep track of the .mny file it starts with? In the registry. > If I have 2 different .mny files, how does money know which file to open > up. The last one opened or, if you select and open a .mny file without Money already running, that one. -- Chris Cowles Gainesville, FL ...

Outlook 2000 won't startup
I have a new laptop and it has Outlook 2000 on it. When I open Outlook though I get a message that says cannot open my default email folders and a location can't be found to send and receive emails It says click on mail icon in control panel but I can't see one in Control panel I have XP professional. Any ideas? Thanks Tony Tony Williams <tw@invalid.com> wrote: > I have a new laptop and it has Outlook 2000 on it. A new laptop wouldn't have Outlook 2000 on it unless you installed it. Perhaps you mean it's a used laptop that you just acquired. > When I ope...

Print Screen Key disabled
I am trying to use the print screen key to paste and then edit some pictures, but the print screen key is disabled. Is there another way to do this or a way around this? Thanks in advance, Jill Are you trying to paste into Publisher? Can you paste into Paint? -- Mary Sauer MS MVP http://office.microsoft.com/ http://www.mvps.org/msauer/ news://msnews.microsoft.com "Jill" <anonymous@discussions.microsoft.com> wrote in message news:27dee01c4635e$6d53f170$a301280a@phx.gbl... > I am trying to use the print screen key to paste and then > edit some pictures, but the print...

unable to disable macro
Hi, Every user is have a warning message when they start up excel. The warning is about compile error from a addin/macro (xla file) that a third party application integrated into Excel (We are running excel 2000). I would like to disable it when Excel is launched, however, there doesn't seem to be a way to do it. I looked at the macro/security/addins and I can't find any reference to it. Can someone suggest me what to check next? Thanks Can you turn it off via: Tools|Addins (and uncheck that addin) Or if the .xla file is in the XLStart folder, you can move it to some other ...

command line startup options
I have a workbook with four sheets. I'd like to create a shortcut for each of four users that opens to their sheet and performs an action. After reading about Command() and the GetCommandLineA API I'm still stuck. GetCommandLineA crashes when run during Excel startup and only returns the workbook path/name when run from the VBA IDE. Is there a way to open a workbook depending upon passed in parameters? "msnews" <msnews@msnews.com> wrote in message news:%235TLuoD1HHA.536@TK2MSFTNGP06.phx.gbl... >I have a workbook with four sheets. I'd like to create a ...

Outlook 2007 totally disabled
New man on the block (Executioner's that is :( ) 1. MS Office 2000 installed on Vista OS. All email accounts, including Hotmail, operable using Outlook, with Outlook Connector. 2. Installed Enterprise 2007 and uninstalled (apparently not all of) Office 2000. 3. Accessing Outlook 2007 from desktop icon produces error "The Add-in "Outlook Connector Extenions" (msncon32.dll) cannot be loaded and has been disabled by Outlook. Please contact Add-in manufacturer for an update. If no update available uninstall the Add-in". 4. Now Outlook 2007 is totally inop...

Disabling "Mailto:" ???
I want to have e-mail addresses entered in an Excel spreadsheet but I DO NOT want my *@$%!)% e-mail reader to be woken up every time I click on one of these cells. How do I disable this automatic baloney? Thanks. Change your preferences in the AutoCorrect Options. Davej wrote: > I want to have e-mail addresses entered in an Excel spreadsheet but I > DO NOT want my *@$%!)% e-mail reader to be woken up every time I click > on one of these cells. How do I disable this automatic baloney? > Thanks. Right-click on the link. Choose "remove hyperlink." HTH Craig Davej wrot...

VBA, Sometimes Loads, Sometime Disabled
I'm Excel/Access/VBa developer, and I've noticed that coded workbooks intially open with VBA enabled, but subsequent workbooks do not. Sometimes they do. In other instances, closing a coded workbook, but leaving Excel open, prevent the next coded workbook from loading VBA, but if the application is closed and another coded workbook is opened, it loads fine. Why? It is not my code, but also another developer's coded books that do the same thing. Macro security is set to medium, and the workstations are locked down becuase we are in a large corporate enviroment. Hi, I'm n...

Windows 7
I am running Win7 Starter Edition on a Dell netbook. I need to enable and disable the wireless and wired network adaptors as I can from Control Panel | Network Connections in XP. How do I do this in Win7? -- ..Bill. click the network icon next to the clock, select your connection, and a button will appear to enable/disable -- kword88 As he said often you have a little tray icon, so rightclick on it. But I don't have any Network trayicons (disabled them) and some people disable icons also, not Ntework itself just the option to show icon. In this case as usual cli...

Disable Secure Sockets Layer on exchange server when using RPC over HTTP
Hi im trying to enable RPC over HTTP to enable users to establish contact to my Excahger server 2003 over the internet. Now, I dont want to use SSL (security not that important) and i am told by this article that i can disable SSL in windows registry. Quote: Note While RPC over HTTP does not require Secure Sockets Layer, you must modify the registry to enable RPC over HTTP if you do not want to use Secure Sockets Layer. Microsoft recommends that you enable and require Secure Sockets Layer for your RPC over HTTP communications. At this address: http://support.microsoft.com/?id=833401 But i ...

Startup problem repost
WindowsXP Pro Sp3 IE8 Posted earlier but did not show as sent. How do I bypass user name and password at startup? -- Ray _________________________________________________ "Ray" <rbarone@.nwi.net> wrote in message news:9Gttn.190907$Jq1.74309@en-nntp-05.dc1.easynews.com... > WindowsXP Pro Sp3 IE8 > > Posted earlier but did not show as sent. > > How do I bypass user name and password at startup? > > -- > Ray > _________________________________________________ > Does this repost mean you can't actually get into...

Programmatically interact with website
In general I am trying to learn how to programmatically interact with software for which I am not aware of a rich library of predefined classes and objects. I thought a good excersize would be opening a website, entering a string into a search box and submitting the search request. (A little background, I am not an experienced programmer. I am decent with VBA and have minimal exposure to C++). I should probably note that I am trying to accomplish this via VS2008. I selected CNET as the target website (mainly because I found it difficult deciphering Google's HTML code). I kno...