Hi,
I have the below code to transfer code modules between Access database files. I have three problems, only one of which is annoying.
a) How do you prevent the Save As box from appearing when the instance of Access is closed? I've tried the acQuitSaveAll as well as the acCmdCompileAnd SaveAllModules route.
b) The On Error line was added when the code was in Access 2003, when I was getting an error message regarding a bad DLL reference when the code hit the Exit Sub at the end. The message description said to check the parameter types or values being passed. This occured consistently but the error would happen, stop the code, I'd step the code on and no error would occur, so I put a Resume Next there to step past it. Under Access 2000 however, this does not occur at all. Any ideas as to why?
c) The code does not consistently perform the import. Stepping through it appears to do what it's supposed to, and if I exit early then it prompts me to save what its done so far. However, when I let it run on a series of seven other databases, some of them don't seem to correctly do the first handful of modules. At first I thought this was to do with the Save As not appearing for those modules so it did not save them, but as a strange quirk, the more times I run this on the same files, the more modules don't get transferred. If it is not to do with the Save As box, I have a suspicion this is to do with the loops and their indexes in the components. Any suggestions?
Regards,
Rob. -
Option Compare Database
-
Option Explicit
-
-
'Stand-alone function to synchronise all files in the same directory as this one.
-
Public Sub RunSynchBatch()
-
Call DoBatchSynchronise(Access.Application)
-
End Sub
-
-
'Cycles through databases in a given directory and performs a synch with this file.
-
'If sCycleDir is not supplied, you will be prompted.
-
Public Sub DoBatchSynchronise(oExportFrom As Access.Application, Optional sCycleDir As String = "")
-
Dim nLoop As Integer
-
-
If sCycleDir = "" Then
-
'Sets the default entry in the prompt to the same directory as this file.
-
With oExportFrom.CurrentDb
-
sCycleDir = Dir(.Name, vbDirectory)
-
sCycleDir = Left(.Name, Len(.Name) - Len(sCycleDir))
-
End With
-
-
sCycleDir = InputBox("Please enter the full path of the directory you wish to update:", "Update Directory", sCycleDir)
-
End If
-
-
With Application.FileSearch
-
.NewSearch
-
.FileType = msoFileTypeDatabases
-
.LookIn = sCycleDir
-
-
If .Execute > 0 Then
-
For nLoop = 1 To .FoundFiles.Count
-
'For each database found, so long as it is not this one, transfers the code.
-
If .FoundFiles(nLoop) <> oExportFrom.CurrentDb.Name Then Call DoSynchroniseCode(oExportFrom, .FoundFiles(nLoop))
-
Next nLoop
-
End If
-
End With
-
End Sub
-
-
'Performs a one-shot export of the code modules in the database open in the oExportFrom instance
-
'of Access to the file specified by sSendTo.
-
Public Sub DoSynchroniseCode(oExportFrom As Access.Application, sSendTo As String)
-
Dim oAccess As Access.Application
-
-
Call oExportFrom.DoCmd.SetWarnings(False)
-
-
'Checks that the file specified is really an Access database.
-
If Right(sSendTo, Len(sSendTo) - InStrRev(sSendTo, ".")) = "mdb" Then
-
'Opens a new instance of Access and opens the specified database.
-
Set oAccess = New Access.Application
-
-
Call oAccess.DoCmd.SetWarnings(False)
-
Call oAccess.OpenCurrentDatabase(sSendTo)
-
Call DoAccessImport(oExportFrom, oAccess)
-
Call oAccess.DoCmd.RunCommand(acCmdCompileAndSaveAllModules)
-
Call oAccess.Quit(acQuitSaveAll)
-
End If
-
-
Call oExportFrom.DoCmd.SetWarnings(True)
-
End Sub
-
-
'Exports all the code files in oExportFrom and imports them into oImportTo.
-
Private Sub DoAccessImport(oExportFrom As Access.Application, oImportTo As Access.Application)
-
Dim sStore As String
-
Dim nLoop As Integer, nComps As Integer
-
-
'Uses the location of the oExportFrom file to create a temporary directory to store the
-
'exported code.
-
With oExportFrom.CurrentDb
-
sStore = Dir(.Name, vbDirectory)
-
sStore = Left(.Name, Len(.Name) - Len(sStore)) & PATH_SYNCH_DIR & "\"
-
End With
-
-
If Len(FileSystem.Dir(sStore, vbDirectory)) <= 0 Then Call FileSystem.MkDir(sStore)
-
-
With oExportFrom.VBE
-
'For each project that exists in the database, cycles through the components which exist
-
'as part of it.
-
For nLoop = 1 To .VBProjects.Count
-
With .VBProjects(nLoop).VBComponents
-
For nComps = 1 To .Count
-
With .Item(nComps)
-
'Currently only performs this with Standard and Class modules.
-
If .Type = vbext_ct_StdModule Or .Type = vbext_ct_ClassModule Then
-
'Exports the module into a text file so it can be imported.
-
Call .Export(sStore & .Name & ".txt")
-
Call DoImportModule(oImportTo, .Name, sStore)
-
End If
-
End With
-
Next nComps
-
End With
-
Next nLoop
-
End With
-
End Sub
-
-
'Searches through the target database to check if the module being transferred already exists.
-
'If it does, then removes the module before importing the one exported from the main database.
-
Private Sub DoImportModule(oSearch As Access.Application, sName As String, sStoreDir As String)
-
On Error Resume Next
-
-
Dim nLoop As Integer, nComps As Integer
-
-
With oSearch.VBE
-
'NOTE: If you have more than one project in the target database, this will import the
-
'requested code module into all of them.
-
For nLoop = 1 To .VBProjects.Count
-
With .VBProjects(nLoop).VBComponents
-
For nComps = 1 To .Count
-
'Checks that it has found a module of the same name, and that it is a
-
'standard or class module.
-
If .Item(nComps).Name = sName And _
-
(.Item(nComps).Type = vbext_ct_StdModule Or _
-
.Item(nComps).Type = vbext_ct_ClassModule) Then
-
'Removes the module so that when the import is done you don't get auto-
-
'numbered versions of the module.
-
Call .Remove(.Item(nComps))
-
Exit For
-
End If
-
Next nComps
-
-
Call .Import(sStoreDir & sName & ".txt")
-
End With
-
Next nLoop
-
End With
-
End Sub
-
0 1596 Sign in to post your reply or Sign up for a free account.
Similar topics |
by: joieva |
last post by:
I would like to know how we can transfer data through a
secured channel to a non-secured site. I am designing an
e-commerce site and getting data from secured site
database(on a firewall) and display to my site. Thank you.
|
by: Glauco |
last post by:
hi to all,
i'm planning to make a way to transfer file with python.
I would like to make the transfer using some crypto api,
to make the channel secure.
i don't want to write a wrapper to ftp or to scp i just
want to make a new protocol, for a little application.
i took a quick look to some cryptographic modules available
in python...
|
by: James Cameron |
last post by:
Hi I'm developing a program and the client is worried about future
reuse of the code. Say 5, 10, 15 years down the road. This will be a
major factor in selecting the development language. Any comments on
past experience, research articles, comments on the matter would be
much appreciated. I suspect something like C would be the best based
on...
|
by: Lauren Wilson |
last post by:
Hi folks,
Can someone point me to some resources on how to control FTP sessions
from and Access application with VBA?
Many thanks for all help.
--LW.
|
by: Shaun Wilde |
last post by:
I am trying to handle a 404 errors and redirect them to the correct page
based on criteria
I was hoping to catch the error in the global error handler and forward via
Server.Transfer to the correct page such that it would appear to be the page
requested. ow this does work to a fashion but it seems that I don't have
access to the session...
| |
by: Bart Van der Donck |
last post by:
Hello,
I'm posting the software for one-FAQ-a-day as described on
http://tinyurl.com/qcxw7
(comp.lang.javascript, July 18 2006, titled "CLJ newsgroup FAQ)
and on
http://tinyurl.com/ppt2s
(comp.lang.javascript, July 22 2006, titled "Automation of
comp.lang.javascript FAQ")
|
by: Valli |
last post by:
Hi,
My project contains 20 htm pages. All these page conatins login button
where the click of login button transfers to login.htm page. All these
modules were designed by my colleague. My part is to design aspx pages &
include that with htm pages.
I have designed the login page named as Default.aspx. Now this Default.aspx
must be...
|
by: Saurabh |
last post by:
Dear All,
Can anyone tell me, how to write such a program that can transfer
files (either binary or text) behind NAT devices( such as for
computers behind firewalls and routers and other NAT devices) using
TCP socket programming.
I have a mechanism through which the public IP of the router and Port
number will be forwarded to me. But...
|
by: archdin |
last post by:
Hello experts,
I m working in SAP.
But this time i m working on program of weighbridge.
An ABAP application is developed to get the vehicle and material information along with the gross and tare weight of vehicles. The application executes a visual basic program on the local PC that captures U] weight data from the Avery digitizer and...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it. ...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...
| |