Need Help to "Create Object"

D

Dale

Access 2000

I have a check scanner from Magtek, (MicrImage) This is like a "point
of sale" check scanner/credit card reader. Magtek furnished 2 ocx's
(MTMicrImage.ocx & SaxComm8.ocx). They also give example VB code.


I need to make this work in Access. I know the following code will
require a lot of modification for VBA.


My Problem is getting started - I have copied the ocx's to the
system32 folder and registered them. I also have a reference to them
in Access.


How do I create the "Object" so I can use the methods of the ocx?


Here is the VB code Example -


**************************************************************


Private Sub LogStatus(ByVal InfoToLog As String)


txtStatus.Text = txtStatus.Text & InfoToLog & vbCrLf


txtStatus.SelLength = 0


txtStatus.SelStart = Len(txtStatus.Text)


End Sub


Private Sub cmdClear_Click()


txtStatus.Text = ""


txtMagStripeData.Text = ""


txtFirstName.Text = ""


txtLastName.Text = ""


txtMonth.Text = ""


txtYear.Text = ""


txtTrack1.Text = ""


txtTrack2.Text = ""


txtTrack3.Text = ""


txtAccountNum.Text = ""


txtMicrData.Text = ""


txtMicrAccountNum.Text = ""


txtCheckNum.Text = ""


txtTransit.Text = ""


txtFileName.Text = ""


txtIFD.Text = ""


txtTagNum.Text = ""


txtTagOutput.Text = ""


cmdGetTagByNum.Enabled = False


cmdGetAllTags.Enabled = False


End Sub


Private Sub cmdExit_Click()


Unload Me


End Sub


Private Sub cmdGetAllTags_Click()


Dim ReturnVal As Variant


Dim FieldCount As Integer


Dim i As Integer


Dim TagNum As Long


LogStatus "Getting All Tags in file " & txtFileName.Text & ": "


ReturnVal = MicrImage.EnumTiffTags(txtFileName.Text, txtIFD.Text)


If IsArray(ReturnVal) Then


FieldCount = UBound(ReturnVal)


LogStatus "There are " & FieldCount & " Tags"


For i = 1 To FieldCount


TagNum = MicrImage.GetTiffTagNumByIndex(txtFileName.Text, i,
txtIFD.Text)


LogStatus " Tag # " & TagNum & "= " &
MicrImage.GetTiffTagByNumber(txtFileName.Text, TagNum, txtIFD.Text)


Next


Else


LogStatus "There are No Tags in IFD " & txtIFD.Text & " in file " &
txtFileName.Text


End If


End Sub


Private Sub cmdGetTagByNum_Click()


LogStatus "Getting Tag By Tag Number:"


txtTagOutput.Text = MicrImage.GetTiffTagByNumber(txtFileName.Text,
txtTagNum.Text, txtIFD.Text)


End Sub


Private Sub cmdPortOpen_Click()


If Not (MicrImage.PortOpen) Then


MicrImage.CommPort = txtCommPort.Text


MicrImage.Settings = txtSettings.Text


End If


MicrImage.PortOpen = Not MicrImage.PortOpen


If MicrImage.PortOpen Then


LogStatus "Port Opened"


cmdPortOpen.Caption = "Close Port"


If MicrImage.DSRHolding Then


LogStatus "Device Attached"


'Displays Current Switch Settings


'If you use the MicrImage.Save command then these do not need to be
sent


'every time you open the device


MicrImage.MicrTimeOut = 1


LogStatus "These are the Current Switch Settings"


LogStatus " Switch A: " & MicrImage.MicrCommand("SWA", True)


LogStatus " Switch B: " & MicrImage.MicrCommand("SWB", True)


LogStatus " Switch C: " & MicrImage.MicrCommand("SWC", True)


LogStatus " Switch D: " & MicrImage.MicrCommand("SWD", True)


LogStatus " Switch E: " & MicrImage.MicrCommand("SWE", True)


LogStatus " Switch I: " & MicrImage.MicrCommand("SWI", True)


LogStatus " Switch HW: " & MicrImage.MicrCommand("HW", True)


'Sets Switch Settings


'If you use the MicrImage.Save command then these do not need to be
sent


'every time you open the device


MicrImage.MicrCommand "SWA 00100010", False


MicrImage.MicrCommand "SWB 00100010", False


MicrImage.MicrCommand "SWC 00100000", False


MicrImage.MicrCommand "HW 00111100", False


MicrImage.MicrCommand "SWE 00000010", False


MicrImage.MicrCommand "SWI 00000000", False


'MicrImage.Save


'Displays New Settings


'If you use the MicrImage.Save command then these do not need to be
sent


'every time you open the device


LogStatus "These are the New Switch Settings:"


LogStatus " Switch A: " & MicrImage.MicrCommand("SWA", True)


LogStatus " Switch B: " & MicrImage.MicrCommand("SWB", True)


LogStatus " Switch C: " & MicrImage.MicrCommand("SWC", True)


LogStatus " Switch D: " & MicrImage.MicrCommand("SWD", True)


LogStatus " Switch E: " & MicrImage.MicrCommand("SWE", True)


LogStatus " Switch I: " & MicrImage.MicrCommand("SWI", True)


LogStatus " Switch HW: " & MicrImage.MicrCommand("HW", True)


'The OCX will work with any Micr Format. You just need to know which


'format is being used to parse it using the FindElement Method


LogStatus "Changing Format to 6200 for this Demo"


MicrImage.FormatChange "6200"


LogStatus "Version: " & MicrImage.Version


MicrImage.MicrTimeOut = 2


Else


LogStatus "Device Not Attached"


End If


Else


LogStatus "Port Closed"


cmdPortOpen.Caption = "Open Port"


End If


End Sub


Private Sub Form_Load()


txtCommPort.Text = MicrImage.GetDefSetting("CommPort", "1")


txtSettings.Text = MicrImage.GetDefSetting("Settings", "115200,N,
8,1")


lblCaption(0).Caption = App.ProductName


lblCaption(1).Caption = App.ProductName


End Sub


Private Sub MicrImage1_MicrDataReceived()


Dim ImagePath As String


Dim ImageFileName As String


Dim ImageIndex As String


Dim Status As Long


Dim StatusMsg As String


Dim bOpStatus As Boolean


If MicrImage.GetTrack(1) & MicrImage.GetTrack(2) &
MicrImage.GetTrack(3) <> "" Then


LogStatus "Event Fired: MagStripe Data"


txtMagStripeData.Text = MicrImage.MicrData


txtFirstName.Text = MicrImage.GetFName()


txtLastName.Text = MicrImage.GetLName()


txtMonth.Text = MicrImage.FindElement(2, "=", 2, "2", False)


txtYear.Text = MicrImage.FindElement(2, "=", 0, "2", False)


txtTrack1.Text = MicrImage.GetTrack(1)


txtTrack2.Text = MicrImage.GetTrack(2)


txtTrack3.Text = MicrImage.GetTrack(3)


txtAccountNum.Text = MicrImage.FindElement(2, ";", 0, "=", False)


Else


LogStatus "Event Fired: Micr Data"


txtMicrData.Text = MicrImage.MicrData


txtMicrAccountNum.Text = MicrImage.FindElement(0, "TT", 0, "A",
False)


txtCheckNum.Text = MicrImage.FindElement(0, "A", 0, "12", False)


txtTransit.Text = MicrImage.FindElement(0, "T", 0, "TT", False)


ImagePath = MicrImage.GetDefSetting("ImagePath", "C:\")


'This sets up and index number so that we can deal with same check
being


'inserted over and over. The TransmitCurrentImage Method with fail if
the file


'already exists. This is to ensure that no check image is
overwritten.
By keeping


'an ImageIndex and incrementing it we ensure that the same file name
will not be


'generated below. You are free to name the file anything that is
considered to be


'a valid file name.


ImageIndex = MicrImage.GetDefSetting("ImageIndex", "0")


ImageIndex = CStr(CInt(ImageIndex) + 1)


MicrImage.SaveDefSetting "ImageIndex", ImageIndex


ImageFileName = ImagePath & "MI" & txtTransit.Text &
txtMicrAccountNum.Text & txtCheckNum.Text & ImageIndex & ".TIF"


LogStatus "Acquiring File: " & ImageFileName & " ..."


'Adding a tiff tag.


MicrImage.AddTag ("T32768=This was added by the Demo Program")


'Transmitting current image


Status = MicrImage.TransmitCurrentImage(ImageFileName, StatusMsg)


'Logging status of TransmitCurrentImage


LogStatus "TransmitCurrentImage: " & Status


If Status = "0" Then


bOpStatus = ShellEx(ImageFileName, , , , , Me.hWnd)


If bOpStatus = True Then


LogStatus "Shell Successful"


'setting up the Image Info


txtFileName.Text = ImageFileName


txtIFD.Text = "1"


txtTagNum.Text = "270"


cmdGetTagByNum.Enabled = True


cmdGetAllTags.Enabled = True


Else


LogStatus "Shell Failed"


cmdGetTagByNum.Enabled = False


cmdGetAllTags.Enabled = False


End If


End If


End If


MicrImage.ClearBuffer


End Sub


Private Sub mnuAbout_Click()


frmAbout.Show vbModal


End Sub


Private Sub mnuExit_Click()


Unload Me


End Sub


******************************************************


Thanks
Dale
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top