Apologies for this being only a partial SUM. Its the end of the tax year
here in the UK and this little task just keeps falling to the bottom of the
ToDo list.
Thanks to Caroline Hilton, Carol Sheehan, Laurence Seeff, Jakob Lanstorp and
many others for all the advice. I am still working on this because I now
need to take this much further...
There are at least two commercially available tools to do this....,
"Maplinker" (uk source: www.pelicangeographics.co.uk )and "MI2Aform"  (go
see: www.cdrgroup.co.uk )
I havent had time to look closely at either of these, but they appear to do
what most users want..

Ok, the problem:- I needed a way of clicking on a mapinfo mapobject and
getting the relevent attribute data in an access table appear in an access
form. 

its fairly easy, i got what i needed using DDE in under 15 mins. (The tricky
bit is writing the error trapping code you'll need to make it bomb-proof).
There are examples using Access as a DDE server in the MS Access Help
files...I recommend these as a start, using Access as a client is my next
job......

The following are the very few lines of code needed in my application, you
can see where i have adopted DDE and the requirements for parsing the
commands etc) 

***********************************************
Some declarations first>>>
Dim Intchan2 as integer        this is a variable for the DDE channel number
I wanted to make sure that the app would fire up MS access so I replaced the
often publicised  DDE method of doing this with an API call, its just a bit
easier to deploy. The following function declaration is  needed...its V
useful as it will fire up any program based on a file extension...so it
could be a doc, xls, wrl, txt, mdb etc etc 
Declare Function MiAccessexecute Lib "shell32.dll" Alias "ShellExecuteA" 
(ByVal hwnd As Integer,
Byval lpOperation As String,byval lpFile As String,Byval lpParameters As
Integer,byval lpDirectory As String,ByVal nShowCmd As Integer) As Integer

ok, so  now i get  mapinfo fired up and a menu option tells the user to pick
an Access table, gets its full path and also trim it down to just its 'name'
Sdatafilepath = FileOpenDlg(sapppath,"","MDB","Open Access Database")
Sdatafilename =PathToFileName$( Sdatafilepath )
I then 'run' that file to guarantee that access is running with at least a
database open (this finds access for me and cuts down on DDEchannel numbers
aa = MiAccessExecute(0,"open", Sdatafilepath, 0, "",1)

the following then initiates a conversation with the open database via its
'name'
intChan2 = DDEInitiate("MSAccess", Sdatafilename)

I now embeded the following commands in a selchangedhandler routine that was
'toggled' by a custom button (but I could have just made a bespoke
tool)..The routine detects a '+1' change in selection, and then grabs the
value held in the first (could be any) column of the mapinfo table , parses
that value as a variable (mapobjid) to access, then deselects
itself.....handy hint!...the handler had a global logical variable attached
to stop it acting recursively...i learned the hard way
mystr = "[OpenForm "+ chr$(34)+ "Employees" + chr$(34)+ ", , ," +chr$(34)+
"EmployeeID = " + mapobjid + chr$(34) +"]"
DDEExecute intChan2, mystr

The mystr line builds an 'OpenForm' command, telling access to open the form
"Employees" and set the control "employeeID" to the mapobjID note the use of
the chr$(34) for >>"<< marks...dont try and do it with """  it gets horrible
very quickly.  thats all i needed! job done!...........the DDEExecute 'runs'
the command and the form has been preset to refresh itself when the
EmployeeID object is changed....

In theory you can issue any command that will act as a method in a VB DoCmd
(so there lots of scope for getting acces to 'work' in the background) You
can also issue a DDERequest$(intchan2,"Formlist") to pull back a tab
delimited list of possible forms.(The example above has WAY TOO much hard
coding for my taste)..but you then need to get heavy with parsingcommands to
find the right Control on the right form form to 'activate'. My next step is
to get access to be the client (it looks fairly easy).  and also tie up
'Commits' to either Access or MI (you can add objects to either at will, but
you 'cant see' them in the 'other' application till you have 'committed' and
refreshed) Basically theres lots to go on and it looks like i will have to
add extra functions in as well, I will sum further if time allows..

This is now a mini project on my to do list , if anyone wants my real code
(it uses the MSAccess dataset Northwind or Nwind  as an 'example') let me
know and i'll send it...be warned... its a bit rough....I only needed a
quick bodge..


Russell Lawley
Geoscientist
British Geological Survey
www.bgs.ac.uk




*********************************************************************
This e-mail message, and any files transmitted with it, are confidential and intended 
solely for
the use of the addressee. If this message was not addressed to you, you have received 
it in
error and any copying, distribution or other use of any part of it is strictly 
prohibited. Any
views or opinions presented are solely those of the sender and do not necessarily 
represent
those of the British Geological Survey. The security of e-mail communication cannot be
guaranteed and the BGS accepts no liability for claims arising as a result of the use 
of this
medium to transmit messages from or to the BGS. The BGS cannot accept any 
responsibility
for viruses, so please scan all attachments.                                           
    http://www.bgs.ac.uk
*********************************************************************

---------------------------------------------------------------------
List hosting provided by Directions Magazine | www.directionsmag.com |
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to