Go Premium for a chance to win a PS4. Enter to Win


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


Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
We live in a world of interfaces like the one in the title picture. VBA also allows to use interfaces which offers a lot of possibilities. This article describes how to use interfaces in VBA and how to work around their bugs.
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…
Suggested Courses

971 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