How to get Access 2k VB Function to work with VB.Net???

Posted on 2008-06-16
Medium Priority
Last Modified: 2013-11-26
I have a front/end Access 2k Disptaching application connected to a MySQL back end server for a client.  Currently we have a xmlgateway vehicle tracking service for which inbound transactions are posted directly to the MySQL server tables and this all works and was developed by a web developer.  Now, on the click of a button, I have to make the Access 2k front/end application send a basic text message to a vehicle through the xmlgateway.  I have the format and structure of the SendOutboundMessage Function provided by the tracking company and it uses VB.Net which is what I'm trying to get a clear understanding on how to make this work since the application is written in Access/VBA.

1.) Obviously I will need a copy of VB.Net to write this function and the question is since the application is Access/VBA, will the entire application have to be converted to VB.Net or can the application use both as long as they both exist on the machine???

2.) Also, at the client site, this appliation is used on several machines and they already have VB.Net on there web server because they can process the InBound transactions.  If I include this function in the Access Front End, will all machines have to have VB.Net installed on them???



Question by:Eric Sherman
  • 3
  • 2
LVL 23

Expert Comment

by:Christopher Kile
ID: 21796768
1.  Access 2k can use ActiveX objects (COM).  You can build such objects in VB.NET.  Build an object to send the message, and accept the message as an argument from Access2K.  Link it in to Access 2k as you would any other COM reference.  Build your button code in Access to intialize the COM object then call the message-sending method.  You have some learning to do here, but if you take this path you won't have to rewrite the Access2k app.

2.  You don't need VB.NET, which is just the development environment for that language, but the proper version of .NET should be installed on each of your client's machines.  Happily, that is usually part of the standard Windows Update process, and thus should cause little or no problem at your client's site.  Talk to your client's IT maintenance people and find out whether they've been installing and updating .NET and what versions they have out there (if they're only deploying .NET version 2.0 and above, you'll need Visual Studio 2005 or later).
LVL 19

Author Comment

by:Eric Sherman
ID: 21796949
Ok, thanks cpkilekofp for the quick reply ...

I think I get the general idea and it will probably be more clear once I get into it.  

Can you explain a bit further the following comments ...

"Build an object to send the message, and accept the message as an argument from Access2K"

"Build your button code in Access to intialize the COM object then call the message-sending method."

I am familiar with COM objects and referencing them in Access but I'm just trying to make sure I understand your approach.



LVL 19

Author Comment

by:Eric Sherman
ID: 21799033
Ok, I guess it would be nice if the tracking company had a API in the form of an ActiveX COM object.  I've used those before for faxing.  Creating that COM object is the confusing part right now but the actual XML code to send the text message is not really that long (account, user, pswd, messagetype, vehicle, messagedata), so I should be able to create it.   I am comparing this to the efax COM object that I currently use.  

For example with efax I would do the following from within a Access VBA module ...

'Instantiate the Main object
Dim api As eFaxDeveloper.IOutboundClient
Set api = New eFaxDeveloper.OutboundClient

'Instantiate a DocumentBundler object
Dim docs As eFaxDeveloper.IDocumentBundler
Set docs = New eFaxDeveloper.DocumentBundler

'Set your eFax Developer account identifier (required)
api.SetAccountID ("xxxxxxxxxx")

'Set your eFax Developer user name (required)
api.SetUserName ("xxxxxxx")

'Set your eFax Developer password (required)
api.SetPassword ("xxxxxxx")

'Set the recipient name for this transmission (optional)
api.SetRecipientName ("xxxxx")

'Set the recipient company name for this transmission (optional)
api.SetRecipientCompany ("Widgets R Us")

'Set the recipient fax number for this transmission (required)
api.SetRecipientFax ("xxxxxxxxxx")

'Add document(s) to the DocumentBundler object
docs.Add (DocumentToSend)
api.SetDocuments docs
'Perform the Post to eFax Developer

Here's what I am trying to figure out according to your first comments.

1.) How to create the COM object that would accept the AccountID, Username, Password, MessageType, VehicleName, MessageData???

2.) Then, how would you tell it to Post as shown above with the efax COM object???



LVL 23

Accepted Solution

Christopher Kile earned 2000 total points
ID: 21803407
1.  Here's the beauty of .NET and VB.NET:  In order to build a COM DLL using Visual Studio, you simply build a .NET DLL, add classes to it, then specify that each object, and the project itself, are assigned a GUID.  I don't know whether you've worked with objects and classes in VB prior to .NET, but Visual Basic 6.0 (which is 100% dialect-compatible with the Visual Basic for Applications that you are running in A2K supported construction of single-layer classes (no inheritance).    http://msdn.microsoft.com/en-us/library/x66s8zcd(VS.71).aspx links to a walkthrough of how to use VB in VS.NET to create COM objects.

2.  You write a method for that COM object that will be publicly exposed for use that will do the work by reading the properties of the object, formatting the message, then sending the message using .NET APIs.  You can call that method PostMessage().  A method is just an object-based name for a subroutine or function that is defined within the object (just like a subroutine or function is defined in a module).  

LVL 19

Author Comment

by:Eric Sherman
ID: 21804132
Thanks cpkilekofp ... Your comments have pointed me in the right direction.  I have been playing around with Visual Basic 2008 Express edition and have realized that the full version will be need to accomplish what I'm trying to do.  The Express is designed for beginners and creating COM objects would not be considered something beginners would be involved in so most of the features are not included.

Much Appreciated ...


Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Instead of error trapping or hard-coding for non-updateable fields when using QODBC, let VBA automatically disable them when forms open. This way, users can view but not change the data. Part 1 explained how to use schema tables to do this. Part 2 h…
Hello there! As a developer I have modified and refactored the unit tests which was written by fellow developers in the past. On the course, I have gone through various misconceptions and technical challenges when it comes to implementation. I would…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…
Suggested Courses

612 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question