UtterAccess.com
X   Site Message
(Message will auto close in 2 seconds)

Welcome to UtterAccess! Please ( Login   or   Register )

Custom Search
 
   Reply to this topicStart new topic
> Acccess And Card Readers, Any Version    
 
   
Tiesto_X
post May 4 2012, 05:21 AM
Post#1



Posts: 335
Joined: 27-July 10



Hi,
I never worked with Card Readers. Now, customer wants program to track employers when they check in and check out.
I don't understand how Access read data from Card.
Any tip, where to start?
This is the Card Reader that they have:
THE CARD READER LINK
Go to the top of the page
 
jleach
post May 4 2012, 06:08 AM
Post#2


UtterAccess Administrator
Posts: 10,441
Joined: 7-December 09
From: St. Augustine, FL


Hi,
It's been a long time since I looked at this, and even then I didn't actually use it but just got a glance, but here's how I recall that they work, in general:
The card reader comes with hardware (to read), and it's own softare which takes the information from the card reader and converts it to some more or less standard information readable by application software (this may be in many formats, but it should be in some format that can be universally handled).
Access (or rather, VBA, or whatever other language is being used to write the logic) interacts with the Card Reader's API (Application Programming Interface). This may be very similar to using an ActiveX object, or perhaps more along the lines of programming external DLL functions as we would with the Win32 API. In either case, the key is that the software receives information from the hardware and provides us with some sort of interface that allows us to interact with that information (likely as well as some rudimentary Events for triggering when the information becomes available, etc).
This is my basic understanding of how it works, though again I'll offer a disclaimer that I've never actually used such devices, nor programmed any.
Hopefully that gives some basic direction at least. You may find more readily available but similar concept information by searching for Bar Code Scanner integration with VBA (or other languages... if you can psuedo-read code it's helpful in getting the basic "gist" of how some things will work)
Go to the top of the page
 
jleach
post May 4 2012, 06:16 AM
Post#3


UtterAccess Administrator
Posts: 10,441
Joined: 7-December 09
From: St. Augustine, FL


Takng a look at the link, then going to the product sheet (http://www.gemalto.com/products/pc_link_readers/) and clikcing the "Technical Specifications" tab, scroll down and you will see the "API" category which provides the following information:
Microsoft PC/SC environment with associated drivers
CT-API
Synchronous Card API for support of memory cards
The first of that list sounds like it'd be the ideal place to start some research for using VBA. Smart Cards (MSDN) (this looks awfully dated... back to Win 98/95 even, with no mention of OS's past XP... although Win32 API is Win32API and should still be supported as such) Particularly you'll want to pay attention to the Interoperability section and the Software Development section.
Good luck! There's some work there...
Cheers,
Go to the top of the page
 
Tiesto_X
post May 4 2012, 09:38 AM
Post#4



Posts: 335
Joined: 27-July 10



Hi sir,
That is good post for the beginning.
I will keep in mind your words and hopefully that Smart Cards article has something useful.
Big thanks for your time!
Go to the top of the page
 
Tiesto_X
post May 7 2012, 04:11 AM
Post#5



Posts: 335
Joined: 27-July 10



Hi,
Ofound, hope so, good article.
Since the code is too complex for me I'm not able to implement it into Access, i get compile error.
Any help?
Attached File(s)
Attached File  2239160.zip ( 2.12K )Number of downloads: 130
 
Go to the top of the page
 
jleach
post May 7 2012, 05:10 AM
Post#6


UtterAccess Administrator
Posts: 10,441
Joined: 7-December 09
From: St. Augustine, FL


What line is highlighted on the compile error? At a quick glance they look like all API declarations and they appear to be correct in syntax.
That version of Access are you using? If you're using 64 bit 2010 we'll need to adjust a few things.
Go to the top of the page
 
jleach
post May 7 2012, 05:23 AM
Post#7


UtterAccess Administrator
Posts: 10,441
Joined: 7-December 09
From: St. Augustine, FL


Nevermind, I got the compile error stuff more or less squared away.
dd the following to your module, after the Option Explicit but before all the declarations you posted:
CODE
'http://msdn.microsoft.com/en-us/library/aa379808(v=vs.85).aspx
Public Type SCARD_READERSTATE
  szReader As String
  pvUserData As Long
  dwCurrentState As Long
  dwEventState As Long
  cbAtr As Long
  rgbAtr As Byte
End Type
'http://msdn.microsoft.com/en-us/library/aa922903.aspx
Public Type SCARD_ATRMASK
  cbAtr As Long
  rgbAtr As Byte
  rgbMask As Byte
End Type
'http://msdn.microsoft.com/en-us/library/aa379807.aspx
Public Type SCARD_IO_REQUEST
  dwProtocol As Long
  dwPciLength As Long
End Type

These are structures (User Defined Types (UDTs)) that are required for certain parameters of the API stuff. Once declared, you assign them as a variable type: Dim x As SCARD_ATRMASK etc.
Also, do a Find/Replace in the module and change the following:
ByteArray to Long
Guid to Long
(note that I'm not positive Longs are sufficient for this, but it gets the code to compile for the time being and can be debugged afterwords)
Do you happen to have the link where you found this code by chance? Nice find...
Go to the top of the page
 
jleach
post May 7 2012, 05:56 AM
Post#8


UtterAccess Administrator
Posts: 10,441
Joined: 7-December 09
From: St. Augustine, FL


Just as a side note, I don't know if you've ever gotten into API programming at all... it's a bit of a complex beast, but it can be done. If you're unfamiliar with it, you will definately have your work cut out for you. The following wiki article (unfinished at this time) attempts to give an overall walkthrough of the ins and outs of API programming: API. Perhaps a runthrough of this will give you some ideas of what you'll be working with. It's a bit different mindset than standard VBA programming.
Good luck,
Go to the top of the page
 
Tiesto_X
post May 7 2012, 05:59 AM
Post#9



Posts: 335
Joined: 27-July 10



Hi,
its Windows 7 x64 and Office 2007 x32.
I'm not at home right now, but since user got Windows XP x32 i will need Virtual Machine in test purpose.
'll test code and see what I get.
This is the article link: http://www.rolbe.com/2009/03/01/vb6-winscard-api/
Thank you.
EDIT: I never worked with API, you are right, its BEAST for me, but with your help I have a hope.
I will read Wiki for sure.
Thanks again.
Go to the top of the page
 
jleach
post May 7 2012, 06:13 AM
Post#10


UtterAccess Administrator
Posts: 10,441
Joined: 7-December 09
From: St. Augustine, FL


OS 32bit vs. 64bit will be mostly irrelevant to us, being that the Application we're working with will be using the 32bit OS functions (it's the 64bit Office that gets even more tricky, because it uses the newer 64bit OS architectures).
took a look at the link... the bad news is you should disregard those previous edits I told you about. The good news is that the zip file contains a module that has everything worked up correctly (what I had was a fix to get it compiled, but I didn't think it was correct).
Open the winscard.bas file in the zip provided (it's just a text file) and copy/paste that code into your module. It should compile fine. (note at the top of the module all the Public Types that define the required datatypes).
You can also probably import the file directly... from the VBE in the module list right click then Import then select the file. We'll go from there.
Cheers,
Go to the top of the page
 
Tiesto_X
post May 7 2012, 06:23 AM
Post#11



Posts: 335
Joined: 27-July 10



Glad to hear good news!
copied code into module it does compile, but i need to delete :
CODE
Attribute VB_Name = "winscard"

What should I do with this? Its even above
CODE
Option Compare Database
Option Explicit
Go to the top of the page
 
jleach
post May 7 2012, 06:28 AM
Post#12


UtterAccess Administrator
Posts: 10,441
Joined: 7-December 09
From: St. Augustine, FL


More notes on working with API stuff:
The MSDN contains entries for each of the functions exposed through the API (you'll find these links at the top of each declaration). These give complete instructions and details on how the functions work: it's all there, the problem is deciphering it and makeing use of it. When we're venturing into new API projects, we'll tend to spend a lot of time reading on the function details (or general overviews on the task) to figure out what it is we need to do.
Declaring the API functions and structs (types) are a third of the problem. Finding out how to use those functions as required to complete a task is the second third. Finally, writing and testing the VBA code itself that makes use of the functions in the final third.
We've luckily got one step more or less complete: the API declarations have been spelled out for us. Next is to figure out what's what.... ideally, the MSDN will have an overview article that more or less says to use a card reader, you must do This and This and This and This. If there is such an article present, they should give some very helpful clues as to which MSDN functions we need to be reading about. If not, we'll have to pick one and go from there (generally, an MSDN function documentation will refer to other functions/structs, which then refers to other functions/structs, etc, so if we pick a function from the declaration list at random, chances are we'll end up touching base on many of the others before we're done... take notes while you're going through this!)
To find related information (such as overview articles) in the MSDN, often the left sidebar will have a sort of treeview which has the functions listed. Sometimes, you can work your way back up a few levels to get overview details. Sometimes, though, you're just stuck with the functions themselves.
This is general API investigation work. Luckily though, the other files in that zip are VB6 files which I'm guessing provide some sort of examples on how to actually do this, which may save tons of work in testing and trying to make sense of the ever-fun MSDN documentation.
Even though this project was done in VB6, much of it can still be made use of for VBA. For example, even though we probably can't import the "Form1.frm" VB6 Form object to our Access project, we can open the file with a text editor (notepad++ is highly recommended) and get some clues as to the form's construction, as well as the code contained in the form's module. With a little investigation, this may tell us what functions need to be called in what order, so on and so forth. (also note that the zip file contains a "PCSC_API_Test.exe" or "SimplePC_SC.exe", which are presumably the compiled output of the VB6 project(s), and may be able to be used as a testing tool to see if the thing does what's required or not.)
That should do for now...
Cheers,
Go to the top of the page
 
jleach
post May 7 2012, 06:29 AM
Post#13


UtterAccess Administrator
Posts: 10,441
Joined: 7-December 09
From: St. Augustine, FL


The "Attribute" line is put in when you output a file from VB/VBA. Delete it from the code, it's a behind the scenes thing and not required (by us anyway).
ption Compare Database and Option Explicit are only allowed once, and must be at the very top of the module.
Go to the top of the page
 
Tiesto_X
post May 7 2012, 06:48 AM
Post#14



Posts: 335
Joined: 27-July 10



You are extremely helpful!
I'll try to do all testings and back with results.
Very thanks for your time.
DIT:
I see in Form that there is ByteArray. How should I declare that in VBA?
Go to the top of the page
 
jleach
post May 7 2012, 07:11 AM
Post#15


UtterAccess Administrator
Posts: 10,441
Joined: 7-December 09
From: St. Augustine, FL


ByteArray is defined as a UDT in the winscard.bas file:
CODE
Public Const DEFAULT_BUFFER_SIZE As Integer = 255
Public Type ByteArray
b(0 To DEFAULT_BUFFER_SIZE) As Byte
End Type
(as is Guid, when you see what one as well):
CODE
Public Type GUID
Data1 As Long
Data2 As Integer
Data3 As Integer
Data4(0 To 7) As Byte
End Type
Go to the top of the page
 
JVanKirk
post Jul 20 2015, 10:23 AM
Post#16


UtterAccess VIP
Posts: 4,243
Joined: 4-March 04
From: Clarksville, TN


Any chance the two of you ever figured this out and got it working? I'd love to get a copy of what you did, trying to figure this out myself and have no clue!! I know I can digitally sign Lotus, Adobe, create a signatue in Word and sign with my CAC so this obvioulsy is possible, just not sure where to even start. Also, if you did, this would be a great add to the code archives!!
Go to the top of the page
 
haresfur
post Jul 21 2015, 05:28 PM
Post#17



Posts: 303
Joined: 4-April 12
From: Bendigo, Australia


Gee I'm getting old. My first thought was, "Who uses punch cards any more?"
Go to the top of the page
 


Custom Search


RSSSearch   Top   Lo-Fi    22nd February 2020 - 12:49 AM