473,695 Members | 2,600 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Changing a Library Reference

Some months ago, we requested help from this newsgroup on how to replace
the library reference of a database with another library reference,
prior to creating an MDE. I got the following answer from Stephen K.
Young, which does the job:
In message <ah************ @ID-65843.news.dfnc is.de>, Stephen K. Young
<s@k.y.invalid > writes
Using automation you can temporarily replace a developer library reference
with a compiled library reference. Sample code below. Then continue with
automation to compile the .Mde as before. Afterwards you probably want to
use automation again to reverse the front-end references back to your
un-compiled developer library.

- Steve
For lngRef = appAccess.Refer ences.Count To 1 Step -1 ' loop backwards,
one-based
Set ref = appAccess.Refer ences(lngRef)
If ref.Name = strRefName Then
appAccess.Refer ences.Remove ref
Endif
Next lngRef

<Snip>

I added a:

AppAccess.OpenC urrentDatabase (DbFileName)

at the start to open the database with which to work.

This works fine, apart from one minor problem - when the database is
opened, the AutoExec or Startup form starts running unless I keep my
finger on the shift key.

Is there another way of opening the database, or of preventing the code
from running?

Thanks
--
Zippy S

Email: Zi********@thed essers.com
Nov 12 '05 #1
2 4126
Zippy <Zi***@111.1.1. 1> wrote in message news:<fn******* *******@thedess ers.com>...
Some months ago, we requested help from this newsgroup on how to replace
the library reference of a database with another library reference,
prior to creating an MDE. I got the following answer from Stephen K.
Young, which does the job: .... Is there another way of opening the database, or of preventing the code
from running?


Zippy emailed me directly, so I am posting a reply here.

In my application startup code, I use the trick of checking the
command line parameter to see if any special processing should be
performed. For example, if the command line has a substring
";Continue; ", then my startup code knows to skip certain processing
and let automation take control. (Other substrings delimited by
semicolons can be used to perform additional branching.)

In the startup code, I have something like this:

If (InStr(Command$ (), ";Continue; ") <> 0&)
... ' skip user setup
Else
... ' perform user setup
End If

The code below is a sample programmer function that uses automation to
reset the library reference to a compiled version, prior to compiling
the application itself as a .Mde. (This step needed because you cannot
compile an application unless its library references are also
compiled.) This code resides in a separate programmer application, NOT
the user application.

In the code, the following line sets the command line substring to
control the application startup:

appAccess.SetOp tion "Command-Line Arguments", ";Continue; "

In addition, there is some automation code to close any startup forms.
(The user application uses the standard technique of opening a hidden
startup form to know when the user tries to shut down. My startup code
could skip opening the hidden form entirely, based on the command
line, and maybe it does, but I can't remember now and this code checks
for it anyway.)

Anyway, here is the code to reset a library reference. Watch for
word-wrap. I've removed a few lines relevant to me only, so I have not
actually tested this precise version.

' Replace a reference in an external Access session
' Manipulating references may lose global variables in the db, so the
calling program cannot depend on globals.
' Mde or compiled databases cannot manipulate references at all.
' Example: RefReplace "E:\MyPath\MyAp p.Mdb", "MyLib",
"E:\MyPath\MyLi g.Mde" ' change it
' Example: RefReplace "E:\MyPath\MyAp p.Mdb", "MyLib",
"E:\MyPath\MyLi g.Mdb" ' put it back

Public Function RefReplace(strD bName As String, strRefName As String,
strRefPath As String) As Boolean

On Error GoTo ErrExit
If Not isPathOk(strRef Path) Then
MsgBox "The reference path does not exist: " & strRefPath
Exit Function
End If

' open the database via automation
Dim appAccess As Access.Applicat ion
Dim ref As Reference, lngRef As Long
Set appAccess = CreateObject("A ccess.Applicati on." &
Left$(SysCmd(ac SysCmdAccessVer ), 1)) ' use correct version
appAccess.UserC ontrol = True ' this forces appAccess.Visib le = True
automatically
appAccess.SetOp tion "Command-Line Arguments", "continue;" &
cstrCmdDebug
appAccess.OpenC urrentDatabase strDbName, False

' close the hidden form that may be running and set the shutdown
flag
If appAccess.SysCm d(acSysCmdGetOb jectState, acForm, "fsysSystem ") <>
0 Then
appAccess.Forms ("fsysSystem"). gisAppShutDown = True
appAccess.DoCmd .Close acForm, "fsysSystem ", acSaveNo
End If

' close any other forms such as frmDbBrowse or frmClassif
For lngRef = appAccess.Forms .Count - 1 To 0 Step -1
appAccess.DoCmd .Close acForm, appAccess.Forms (lngRef).Name,
acSaveNo
Next lngRef

' remove the prior reference if any
'Debug.Print appAccess.Refer ences.Count
DoEvents
For lngRef = appAccess.Refer ences.Count To 1 Step -1 ' loop
backwards, one-based
Set ref = appAccess.Refer ences(lngRef)
If ref.Name = strRefName Then
appAccess.Refer ences.Remove ref
Exit For
End If
Next lngRef
Set ref = Nothing

' add new reference
DoEvents
On Error Resume Next
appAccess.Refer ences.AddFromFi le strRefPath
If Err <> 0& Then
MsgBox Err.Description , vbCritical, "RefReplace error adding
reference to " & strRefPath
Err.Clear
Else
DoEvents
appAccess.SysCm d 504, 16483 '<- undocumented call for Compile All
without a module open
If Err <> 0& Then
MsgBox Err.Description , vbCritical, "RefReplace error compiling
all"
Err.Clear
End If
If appAccess.isCom piled = False Then
MsgBox "Database " & strDbName & " was not compiled completely,
perhaps there is a compile error.", vbInformation, "Not Compiled"
End If
End If
appAccess.Quit acQuitSaveNone
If Err <> 0& Then
MsgBox Err.Description , vbCritical, "RefReplace in appAccess.Quit"
Err.Clear
End If
Set appAccess = Nothing
If Err <> 0& Then
MsgBox Err.Description , vbCritical, "RefReplace in Set appAccess =
Nothing"
End If
Exit Function

ErrExit:
MsgBox Err.Description
Stop
Resume
End Function
Nov 12 '05 #2
In article <25************ **************@ posting.google. com>, Stephen K.
Young <st***********@ hotmail.com> writes
Zippy <Zi***@111.1.1. 1> wrote in message
news:<fn****** ********@thedes sers.com>...
Some months ago, we requested help from this newsgroup on how to replace
the library reference of a database with another library reference,
prior to creating an MDE. I got the following answer from Stephen K.
Young, which does the job:

...
Is there another way of opening the database, or of preventing the code
from running?


Zippy emailed me directly, so I am posting a reply here.


[Snip solution]

It seems that Zippy's posts to this newsgroup have not got through, so
she asked be to forward her thanks. The solution was perfect and has
worked a treat. Many thanks to Stephen.
--
Les Desser
(The Reply-to address IS correct - hope Swen ignores it))
Nov 12 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
9336
by: John D | last post by:
I am trying to change the background colour of either a div or a textarea with javascript, but am having problems. I have passed a hex colour value in the variable hval, and with the following code can change the background colour of the whole page, but only (now) want to change either a textarea of a form or a div. I'm stuck. document.bgColor = hval;
2
1562
by: pablo | last post by:
Dear NGers, I want to keep some images just left of some DIVs. But a change in text size leaves my images at the original position. Which event is generated by changing the text size from the toolbar?? tia pablo k
8
10229
by: Mike S. Nowostawsky | last post by:
I tried using the "toUpperCase()" property to change the value of an array entity to uppercase BUT it tells me that the property is invalid. It seems that an array is not considered an object when it is assigned a text literal?? HOW can I change the array value to upper case then? What other method exists for arrays? Ex: var GridArrayName1 = new Array(); GridArrayName1 = new Array ('test-value'); GridArrayName1 = GridArrayName1...
0
459
by: Zippy | last post by:
Some months ago, we requested help from this newsgroup on how to replace the library reference of a database with another library reference, prior to creating an MDE. I got the following answer from Stephen K. Young, which does the job: >In message <ahjurk$t18vo$1@ID-65843.news.dfncis.de>, Stephen K. Young ><s@k.y.invalid> writes >Using automation you can temporarily replace a developer library reference >with a compiled library...
5
12694
by: Martha | last post by:
When I move my mouse over a hyperlink component, the hyperlink does not change color. How do I change the color of a hyperlink when the mouse goes over the hyperlink? or Change the color of a button component when the mouse goes over the button? I am using Microsfot Visual c#.net Version 7.1.3008
4
2326
by: BS | last post by:
Hello everybody We're currently writing an application that consumes a WS. I have added the Web reference for the services which was pointing to a demo site. Everything now works fine. I need to change my reference to point to the live site where the same web service exists. Is there a way for me to add some kind of variable in my code to use one or the url without having 2 sets of references and by code test "if demo then else" or 2...
0
1618
by: Derek Peschel | last post by:
Should I add an RFE to SourceForge too? I'd like a wide audience in case someone has enough experience to comment or is solving the same problem. I'm using the urwid library which uses curses. On my system (Mac OS 10.3.7) I specifically have ncurses. The programs I'm running turn off echoing and set raw mode but don't disable interrupts. For development purposes I like having interrupts, but my preferred keystrokes (WordStar) conflict...
11
7662
by: Toby | last post by:
I am a little new as you can tell by this post. This is my first c# window app and I made all my forms and now trying to go back and change the start up form and it is giving me errors when I change the form name that is below. And help on this would be nice.. Application.EnableVisualStyles();
8
4103
by: brucedodds | last post by:
I've inherited an A2003 application with linked SQL Server 2000 tables in the back end, using the Microsoft SQL Server ODBC driver. We've set up a test SQL Server database. I'd like to automate the process of relinking the application to test/prod. I've found some code examples here of relinking ODBC back ends to different databases, but they involve deleting the table before relinking. My concern is that the primary key information...
0
8649
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, weíll explore What is ONU, What Is Router, ONU & Routerís main usage, and What is the difference between ONU and Router. Letís take a closer look ! Part I. Meaning of...
0
8586
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9137
Oralloy
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. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9004
jinu1996
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 captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8864
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 most users, this new feature is actually very convenient. If you want to control the update process,...
0
8838
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
4351
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 the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3025
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
2
2289
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.