Can't reference an external adp

P

pdrda

I have a need to access an external ade file/project from code running in
another ade project. I have a great utility for working with mdb/mde files.
When the mde application launches it checks the server for an updated/newer
version of itself. The problem is I can't figure out how to access ANY piece
of information that resides inside the external ade file. Ideally I'd like
to use custom database properties in the adp. I figured out how to
create/set the properties but I can't seem to retrieve those properties in
one ade from code running in another ade. I can't set VB references to the
external ade because doing so locks the file and prevents it from being
copied. Any ideas or help. Thanks very much in advance. Paul
 
V

Vadim Rapp

p> I have a need to access an external ade
p> file/project from code running in another ade
p> project. I have a great utility for working with
p> mdb/mde files. When the mde application launches it
p> checks the server for an updated/newer version of
p> itself. The problem is I can't figure out how to
p> access ANY piece of information that resides inside
p> the external ade file. Ideally I'd like to use
p> custom database properties in the adp. I figured
p> out how to create/set the properties but I can't
p> seem to retrieve those properties in one ade from
p> code running in another ade. I can't set VB
p> references to the external ade because doing so
p> locks the file and prevents it from being copied.
p> Any ideas or help. Thanks very much in advance.
p> Paul



Dim o As New Access.Application, DB as Object
o.OpenCurrentDatabase ("db2.mdb")
set db=o.currentdb
<interrogate db>
o.CloseCurrentDatabase
o.Quit acQuitSaveNone


That is, if you know how to interrogate. I did not see any persistent
settable values among the Properties of currentdb.

Vadim
 
B

Baisong Wei[MSFT]

Hi Pdrda,

Thank you for using MSDN Newsgroup! It's my pleasure to assist you with
your issue.

As my understanding of your question, you question is: There is one MDE
application wants to get properties in a table which is in another ADP. You
wonder if there is any method to do so, right? If I misunderstood, please
feel free to let me know.

I did a simple test to get the properties of the a table in database
northwind.mdb.
1. Start a new project saved as adp1.adp.
2. In Access 2000, create a new Form saved as Form1, put four list objects
on the form named list1, list2, list3 and a button. In the VBA development
environment (press Alt+F11), establish a reference to DAO 3.5 by clicking
References from the Tools menu.
3. Add the following code to the Form1_Click procedure:

Private Sub Command8_Click()
Dim MyDB As DAO.Database
Dim MySet As DAO.Recordset
Dim MyProperty As DAO.Property
Dim MyTableDef As DAO.TableDef

' Access database
Set MyDB =
DBEngine.Workspaces(0).OpenDatabase("c:\northwind1.mdb")
'suppose your northwind.mdb is on driver c:
Set MySet = MyDB.OpenRecordset("orders", dbOpenTable)
'Open table "orders"
Set MyTableDef = MyDB("orders")

'display properties collection for Field
For Each MyProperty In MySet(0).Properties
List1.AddItem MyProperty.Name
Next

'display properties collection for Recordset
For Each MyProperty In MySet.Properties
List2.AddItem MyProperty.Name
Next

'display properties collection for Tabledef
For Each MyProperty In MyTableDef.Properties
List3.AddItem MyProperty.Name
Next
MySet.Close
MyDB.Close
End Sub

4. Saved all and then Open Form1, you will get the properties of table
'orders'

Hope this is the methods you are looking for. If you still have any
questions, please feel free to post new message here.

Best regards

Baisong Wei
Microsoft Online Support
 
G

Guest

Baisong

Thanks for the quick response. I guess I wasn't very
clear. I am transitioning to and working in a pure
adp/ade environment using Access XP so there are no
mde/mdb files involved.
My need is to access information actually stored within
one ade file from code running in another ade
file/application. I am not interested in any table data
since all tabel data resides in SQL server and not
actually in the ade file.
Functionally, I am trying to store an application version
number/ID in the ade file and then "check" that version
number from code running in a different ade. I really
don't care what mechanism is used to "hold" the value as
long as that value is actually stored in the ade file
somewhere. Concepts I've considered for "holding" the
value include 1)using a custom "property" value, 2)using
a function that returns a hardcoded value, and 3)Using
a "file system property" to hold the version value. All
of these work fine to store/hold the value but I cannot
figure out how to retrieve the value from code running in
an external ade application. The usual approach (IF we
were working with mdbs) would be to use a DAO currentdb()
call to get a handle on the file, but currentdb() will
not return a reference to an ade/adp file.

Thanks again for your help.
Paul
 
B

Baisong Wei[MSFT]

Hi Pdrda,

Thank you for using MSDN Newsgroup! It's my pleasure to assist you with
your issue.

Sorry for the misunderstanding in the first time. So, you want to save some
information in one ade, and want to get this information from another ade,
right? From my experience, you could save this information in a the
customer properties. When you right click the file, such as a .doc, .ppt,
or .ade, you choose the 'properties' and there is a 'Customer' tab, you can
enter your own properties. This could be a place to save the information
(such as the version) and you could get this information in you code.

There is an article that you could refer to:
Dsofile.exe Lets You Edit Office Document Properties from Visual Basic and
ASP:
http://support.microsoft.com/default.aspx?scid=KB;EN-US;224351

There are code in it that you could use to read, add and remove the custom
properties. I attatch the executed application reply. I wonder if this is
the method that could meet your requirement. If you have any problems in
the code there and any other problems, please feel free to post new message
here and I am ready to help!

Best regards

Baisong Wei
Microsoft Online Support
 
P

pdrda

Hello Baisong

Thanks again for your reply.

The Dsofile approach seems to work functionally, thanks for finding it. One
problem remains however in that there is a requirement to register the
ActiveX component on each client workstation. At many clients this is either
not possible or requires very much time, paperwork and money.

There are properties of adp/ade projects that you manipulate such as...
Application.CurrentProject.Properties.Add "ProjectVersion",1.1
Application.CurrentProject.Properties("ProjectVersion") = 1.2
strVersion = Application.CurrentProject.Properties("ProjectVersion")

This works great and requires no extra components (ActiveX or WinAPI calls)
as long as you are working within the open/current ade project. The problem
is (as before) getting that property value out of an external (not the
open/current) project. Is there a way to do this without launching a second
instance of Access?

Thanks again,
Paul
 
B

Baisong Wei[MSFT]

Hi Pdrda,

Thank you for using MSDN Newsgroup! It's my pleasure to assist you with
your issue.

From my experiecne, there is no way to get the property of an external ade
project property without launching it besides the Dsofile methods. The
following:
Application.CurrentProject.Properties.Add "ProjectVersion",1.1
Application.CurrentProject.Properties("ProjectVersion") = 1.2
strVersion = Application.CurrentProject.Properties("ProjectVersion")

could work greatly for current ade project, but cannot get the property of
another ade project properties.

If you have any questions for this issue, please feel free to post new
message here and I am ready to help!

Best regards

Baisong Wei
Microsoft Online Support
 
P

pdrda

OK, Baisong, Thanks.

I'm curious about one thing though. If properties of an
adp/ade cannot be accessed externally do you have any
idea why there are 2 seperate Project objects
(CurrentProject AND CodeProject) within the "Application"
object.? It seems to imply that code in one project can
somehow be executed from code running in an external
project. Any thoughts?
Thanks for all your help.
Paul
 
B

Baisong Wei[MSFT]

Hi Paul,

Thank you for using MSDN Newsgroup! It's my pleasure to assist you with
your issue.

The CurrentProject and CodeProject objects are essentially the same, that
is to refer to the Access project (.adp) or Access database (.mdb), except
that the CurrentProject refers to the current project while CodeProject
refers to the current project in which code is running such as an add-in or
library database. The relationship between CurrentProject and CodeProject
is the same as the CurrentDB and CodeDB functions in previous versions of
Access.

Hope this helps. If you still have questions about it, please feel free to
post new message here and I am ready to help.

Best regards

Baisong Wei
Microsoft Online Support
 

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

Similar Threads


Top