Solved

Late bindingan ActiveX component

Posted on 2007-11-21
9
539 Views
Last Modified: 2008-02-01
Hi experts,

In Belgium everybody gets an ID card with a chip on it containing basic personal information (name, adress etc.) You can buy a very cheap reader that comes with the necessary ActiveX components to link it to your application. I managed to integrate this into my Access 2003 application and it works just fine.

However, if I run my (compiled) application on a machine where the dll's were not installed, it crashes without mercy. Not all my customers have a reader, so that's no good. I looked into late binding, but that throws me an "ActiveX component can't create object"  error. So my question is, is it possible to do late binding on an ActiveX component?

This is the working code I would like to convert to late binding.
----------------------------
Sub TestEID()
Dim EIDlib1 As New EIDLIBCTRLLib.EIDlib
Dim lhandle As Long

Dim RetStatus As New EIDLIBCTRLLib.RetStatus
Dim MapColPicture As New EIDLIBCTRLLib.MapCollection
Dim MapColID As New EIDLIBCTRLLib.MapCollection
Dim MapColAddress As New EIDLIBCTRLLib.MapCollection
Dim CertifCheck As New EIDLIBCTRLLib.CertifCheck

Dim strName As String
Dim strFirstName1 As String
Dim strBirthPlace As String
Dim strBirthDate As String
Dim strGender As String
Dim strNationality As String
Dim strNationalNumber As String

Dim strStreet As String
Dim strZipcode As String
Dim strMunicipality As String

Dim Pasfoto_Temp As Variant

Set RetStatus = EIDlib1.Init("", 0, 0, lhandle)

Set RetStatus = EIDlib1.GetID(MapColID, CertifCheck)

strName = MapColID.GetValue("Name")
strFirstName1 = MapColID.GetValue("FirstName1")
strBirthDate = MapColID.GetValue("BirthDate")
strBirthPlace = MapColID.GetValue("BirthPlace")
strGender = MapColID.GetValue("Gender")
strNationality = MapColID.GetValue("Nationality")
strNationalNumber = MapColID.GetValue("NationalNumber")

Set RetStatus = EIDlib1.GetAddress(MapColAddress, CertifCheck)

strStreet = MapColAddress.GetValue("Street")
strZipcode = MapColAddress.GetValue("ZIPCode")
strMunicipality = MapColAddress.GetValue("Municipality")

Set RetStatus = EIDlib1.GetPicture(MapColPicture, CertifCheck)
Pasfoto_Temp = MapColPicture.GetValue("Picture")

Set RetStatus = EIDlib1.Exit

MsgBox strName & ", " & strFirstName1 & vbCrLf & _
                      strStreet & vbCrLf & _
                      strZipcode & "        " & strMunicipality & vbCrLf, vbOKOnly
End Sub
---------------------------------

thanks,
Michiel
0
Comment
Question by:altiplano
  • 5
  • 3
9 Comments
 
LVL 77

Expert Comment

by:peter57r
ID: 20326495
I don't think i understand the point here.
How does late binding help if the components aren't installed?
0
 

Author Comment

by:altiplano
ID: 20326595
If the card reader isn't installed, the button to read the card should be hidden. I did something similar with Word. If Word is installed, my Access application displays a button that allows the user to merge data into a Word document. With early binding, the application would crash on workstations that do not have Word installed (or a different version).

In the same sence I would think that by using late binding I could prevent the application from crashing on workstations without the card reader.
0
 
LVL 46

Expert Comment

by:tbsgadi
ID: 20326777
Hi altiplano,

You should use conditional compilation

Good Luck!

Gary
0
 
LVL 46

Expert Comment

by:tbsgadi
ID: 20326788
0
Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

 

Author Comment

by:altiplano
ID: 20333086
Thanks Gary,
However, AFAIK conditional compilation is not possible in VBA (Access).
Michiel
0
 
LVL 46

Accepted Solution

by:
tbsgadi earned 500 total points
ID: 20333315
Sorry but I use it in Access all the time!
From the VBA help...

Understanding Conditional Compilation
   

You can use conditional compilation to run blocks of code selectively, for example, debugging statements comparing the speed of different approaches to the same programming task, or localizing an application for different languages.

You declare a conditional compiler constant in code with the #Const directive, and you denote blocks of code to be conditionally compiled with the #If...Then...#Else directive. The following example runs debug code or production code, based on the value of the conDebug variable.

' Declare public compilation constant in Declarations section.
#Const conDebug = 1

Sub SelectiveExecution()
    #If conDebug = 1 Then
        .                ' Run code with debugging statements.
        .
        .
    #Else
        .                ' Run normal code.
        .
        .
    #End If
End Sub

0
 
LVL 46

Expert Comment

by:tbsgadi
ID: 20333320
You can also set it from VBA - Tools - Properties
0
 

Author Comment

by:altiplano
ID: 20333388
Nice, I didn't know that!
It isn't quite the solution I was hoping for,but it certainly is a work around.
regards,
Michiel
0
 
LVL 46

Expert Comment

by:tbsgadi
ID: 20333475
Glad to help!
0

Featured Post

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
subtract 1 in Access 2003 query 7 39
Access 2010 db.Execute using dbFailOnError and dbSeeChanges 10 49
append to an ms access field 6 26
Format a Field AFTER UPDATE 5 29
In the previous article, Using a Critera Form to Filter Records (http://www.experts-exchange.com/A_6069.html), the form was basically a data container storing user input, which queries and other database objects could read. The form had to remain op…
Introduction The Visual Basic for Applications (VBA) language is at the heart of every application that you write. It is your key to taking Access beyond the world of wizards into a world where anything is possible. This article introduces you to…
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…
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

864 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

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now