473,785 Members | 2,480 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 4131
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
9342
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
1565
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
10232
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
12698
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
2329
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
1622
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
7670
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
4106
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
9480
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
10148
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...
0
9950
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
8972
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7499
isladogs
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 instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6740
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 into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5511
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4053
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
3
2879
bsmnconsultancy
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 effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.