Thread: Attaching Code
View Single Post
  #2  
Old August 22nd, 2005, 07:31 PM
Sharkbyte
external usenet poster
 
Posts: n/a
Default

Create a module, to hold the code. Then simply reference the necessary
functions in the OnClick event.

Sharkbyte



"DS" wrote:

How do I attache this code to an Access Command Button?
Thanks
DS


Option Explicit

Public m_hApi As Long 'handle to the printer
Public m_DrvN As String 'name of the driver
Public m_PrtN As String 'name of the printer
Public m_Status As Long 'status of the printer
Public m_InkStatus As Long 'status of the Ink
Public m_Result As Byte 'Eject/Retract sheet result
Public m_reforOfflineSt As Byte 'off-line Status
Public m_MICRReadBuffSize As Byte 'for MICR Data
Public m_MICRReadBuff(255) As Byte 'for MICR Data
Public m_MICRReadStatus As Byte 'for MICR read status
Public m_MICRReadStDetail As Byte 'for MICR detail of read status
Public m_ImageReadBuffSize As Long 'for Image Data
Public m_ImageReadBuff(4194304) As Byte 'for Image Data
Public m_ImageXsize As Byte 'for Image Data
Public m_ImageReadStatus As Byte 'for Image read status
Public m_ImageReadStDetail As Byte 'for Image detail of read status
Public m_ImageName As String 'for MICR Data
Public m_RetransmissionName As String 'for MICR Data
Public m_ESCNFlg As Boolean 'Scanner Extensive Function
Enable/Disable Flag
Public m_FileIndex As Long '"Store Image" button clicked times

'BiOpenMonPrinter Argument
Public Const TYPE_PORT As Long = 1
Public Const TYPE_PRINTER As Long = 2

'BiOpenDrawer Argument
Public Const EPS_BI_DRAWER_1 As Long = 1
Public Const EPS_BI_DRAWER_2 As Long = 2

Public Const EPS_BI_PULSE_100 As Long = 1
Public Const EPS_BI_PULSE_200 As Long = 2
Public Const EPS_BI_PULSE_300 As Long = 3
Public Const EPS_BI_PULSE_400 As Long = 4
Public Const EPS_BI_PULSE_500 As Long = 5
Public Const EPS_BI_PULSE_600 As Long = 6
Public Const EPS_BI_PULSE_700 As Long = 7
Public Const EPS_BI_PULSE_800 As Long = 8

'BiSCNSetImageQuality() Argument
' Color Option
Public Const EPS_BI_SCN_MONOCHROME As Byte = 48 ' Monochrome
Public Const EPS_BI_SCN_COLOR As Byte = 49 ' Color
' ExOption
Public Const EPS_BI_SCN_AUTO As Byte = 48 ' Auto
Public Const EPS_BI_SCN_MANUAL As Byte = 49 ' Manual

'BiSCNSetImageFormat() Argument
' Format Option
Public Const EPS_BI_SCN_TIFF As Byte = 1 ' TIFF
format(CCITT Group 4)
Public Const EPS_BI_SCN_RASTER As Byte = 2 ' Raster Image
Public Const EPS_BI_SCN_BITMAP As Byte = 3 ' Bitmap
Public Const EPS_BI_SCN_TIFF256 As Byte = 4 ' TIFF
format(Glay scale)
Public Const EPS_BI_SCN_JPEGHIGH As Byte = 5 ' Jpeg
format(High complessed)
Public Const EPS_BI_SCN_JPEGNORMAL As Byte = 6 ' Jpeg
format(Normal)
Public Const EPS_BI_SCN_JPEGLOW As Byte = 7 ' Jpeg
format(Low complessed)

'BiSCNReadImage() Argument
' Select Sheet Option
Public Const EPS_BI_SCN_JOURNAL As Byte = 1 ' Select Journal
Public Const EPS_BI_SCN_RECEIPT As Byte = 2 ' Select Receipt
Public Const EPS_BI_SCN_CHECKPAPER As Byte = 32 ' Select Check Paper
' Timing Optin
Public Const EPS_BI_SCN_TRANSMIT_BATCH As Byte = 48 ' Batch mode
Public Const EPS_BI_SCN_TRANSMIT_SEQUENCE As Byte = 49 ' Sequence mode

'BiESCNEnable() Argument
Public Const CROP_STORE_MEMORY As Byte = 0 ' Saved memory
Public Const CROP_STORE_FILE As Byte = 1 ' Saved file

'BiESCNSetAutoSize() Argument
Public Const CROP_AUTOSIZE_DISABLE As Byte = 0 ' Enabled auto size
Public Const CROP_AUTOSIZE_ENABLE As Byte = 1 ' Disabled auto size

'BiESCNSetRotate()
Public Const CROP_ROTATE_DISABLE As Byte = 0 ' Enabled rotate
Public Const CROP_ROTATE_ENABLE As Byte = 1 ' Disabled rotate

'BiESCNDefineCropArea()
Public Const CROP_AREA_RESET_ALL As Byte = 0 ' Delete all
crop area
Public Const CROP_AREA_ENTIRE_IMAGE As Byte = 1 ' Get entire image

'BiESCNClearImage()
Public Const CROP_CLEAR_ALL_IMAGE As Byte = 0 ' Delete all image
Public Const CROP_CLEAR_BY_FILEINDEX As Byte = 1 ' Delete by
FileIndex
Public Const CROP_CLEAR_BY_FILEID As Byte = 2 ' Delete by FileID
Public Const CROP_CLEAR_BY_IMAGETAGDATA As Byte = 3 ' Delete by
ImageTagData
Public Const CROP_AREA_RIGHT As Long = 65535
Public Const CROP_AREA_BOTTOM As Long = 65535

'API return val error codes
Public Const SUCCESS As Long = 0 ' Success
Public Const ERR_TYPE As Long = -10 ' Error argument
"nType"
Public Const ERR_OPENED As Long = -20 ' Already opened
Public Const ERR_NO_PRINTER As Long = -30 ' there is not
printer
Public Const ERR_NO_TARGET As Long = -40 ' No target printer
Public Const ERR_NO_MEMORY As Long = -50 ' No memory
Public Const ERR_HANDLE As Long = -60 ' Invalid handle
Public Const ERR_TIMEOUT As Long = -70 ' Time out
Public Const ERR_ACCESS As Long = -80 ' Access denied
Public Const ERR_PARAM As Long = -90 ' Parameter error
Public Const ERR_NOT_SUPPORT As Long = -100 ' not support
Public Const ERR_OFFLINE As Long = -110 ' now offline
Public Const ERR_NOT_EPSON As Long = -120 ' not epson printer
Public Const ERR_WITHOUT_CB As Long = -130 ' Without
callback function
Public Const ERR_BUFFER_OVER_FLOW As Long = -140 ' Read buffer
over flow
Public Const ERR_REGISTRY As Long = -150 ' Registry error
Public Const ERR_ENABLE As Long = -160 '
BiOpenMonPrinter() is already called
Public Const ERR_DISK_FULL As Long = -170 ' Capacity of a
disk is insufficient
Public Const ERR_NO_IMAGE As Long = -180 ' No image data
Public Const ERR_ENTRY_OVER As Long = -190 ' Registration
number-of-cases over
Public Const ERR_CROPAREAID As Long = -200 ' No specific
CropAreaID
Public Const ERR_EXIST As Long = -210 ' Already the
same thing
Public Const ERR_NOT_FOUND As Long = -220 ' Not found
Public Const ERR_IMAGE_FILEOPEN As Long = -230 ' Open failure
Public Const ERR_IMAGE_UNKNOWNFORMAT As Long = -240 ' Format injustice
Public Const ERR_IMAGE_FAILED As Long = -250 ' Image creation
failure
Public Const ERR_WORKAREA_NO_MEMORY As Long = -260 ' No memory for
WORKAREA
Public Const ERR_WORKAREA_UNKNOWNFORMAT As Long = -270 ' Image creation
failure because of format injustice
Public Const ERR_WORKAREA_FAILED As Long = -280 ' WORKAREA
creation failure

Public Const ERR_EXEC_FUNCTION As Long = -310 ' Other
API is running (3.01)
Public Const ERR_EXEC_MICR As Long = -320
' Now reading MICR (3.01)
Public Const ERR_EXEC_SCAN As Long = -330
' Now scaning image(3.01)
Public Const ERR_SS_NOT_EXIST As Long = -340 ' Status
service not started (3.01)
Public Const ERR_SPL_NOT_EXIST As Long = -350 '
Spooler service not started (3.01)
Public Const ERR_SPL_PAUSED As Long = -360
' Spooler service paused (3.01)
Public Const ERR_RESET As Long = -400
' Now printer is reseting (3.01)

Public Const ERR_USER_MODE As Long = -999 ' MODE IN error

'Printer Status
Public Const ASB_NO_RESPONSE As Long = &H1 ' No response
Public Const ASB_PRINT_SUCCESS As Long = &H2 ' Finish to print
Public Const ASB_UNRECOVER_ERR As Long = &H2000 ' Unrecoverable
error
Public Const ASB_AUTORECOVER_ERR As Long = &H4000 '
Auto-Recoverable error
Public Const ASB_OFF_LINE As Long = &H8 ' Off-line
Public Const ASB_WAIT_ON_LINE As Long = &H100 ' Waiting for
on-line recovery
Public Const ASB_PANEL_SWITCH As Long = &H200 ' Panel switch
Public Const ASB_PRINTER_FEED As Long = &H40 ' Paper is being
fed by using the PAPER FEED button
Public Const ASB_MECHANICAL_ERR As Long = &H400 ' Mechanical error
Public Const ASB_AUTOCUTTER_ERR As Long = &H800 ' Auto cutter error
Public Const ASB_DRAWER_KICK As Long = &H4 ' Drawer
kick-out connector pin3 is HIGH
Public Const ASB_JOURNAL_END As Long = &H40000 ' Journal paper
roll end
Public Const ASB_RECEIPT_END As Long = &H80000 ' Receipt paper
roll end
Public Const ASB_COVER_OPEN As Long = &H20 ' Cover is open
Public Const ASB_JOURNAL_NEAR_END As Long = &H10000 ' Journal paper
roll near-end
Public Const ASB_RECEIPT_NEAR_END As Long = &H20000 ' Receipt paper
roll near-end
Public Const ASB_SLIP_TOF As Long = &H200000 ' SLIP TOF
Public Const ASB_SLIP_BOF As Long = &H400000 ' SLIP BOF
Public Const ASB_SLIP_SELECTED As Long = &H1000000 ' Slip is not
selected
Public Const ASB_PRINT_SLIP As Long = &H2000000 ' Cannot print
on slip
Public Const ASB_VALIDATION_SELECTED As Long = &H4000000 ' Validation
is not selected
Public Const ASB_PRINT_VALIDATION As Long = &H8000000 ' Cannot print
on validation
Public Const ASB_VALIDATION_TOF As Long = &H20000000 ' Validation TOF
Public Const ASB_VALIDATION_BOF As Long = &H40000000 ' Validation BOF

Public Const INK_ASB_NEAR_END As Long = &H1 'Ink near-end
Public Const INK_ASB_END As Long = &H2 'Ink end
Public Const INK_ASB_NO_CARTRIDGE As Long = &H4 'Cartridge is
not present
Public Const INK_ASB_CLEANING As Long = &H20 'Being cleaned
Public Const INK_ASB_NEAR_END2 As Long = &H100 'Ink near-end2
Public Const INK_ASB_END2 As Long = &H200 'Ink end2

Public Const ASB_PRESENTER_COVER As Long = &H4 'Presenter cover
is open
Public Const ASB_PLATEN_OPEN As Long = &H20 'Platen is open
Public Const ASB_JOURNAL_NEAR_END_FIRST As Long = &H10000 'Journal
paper roll near-end-first
Public Const ASB_RECEIPT_NEAR_END_FIRST As Long = &H20000 'Paper
low(first)
Public Const ASB_PSUPPLIER_END As Long = &H200000 'Paper suppliyer end
Public Const ASB_RECEIPT_NEAR_END_SECOND As Long = &H400000 'Receipt
paper roll near-end-second
Public Const ASB_PRESENTER_TE As Long = &H1000000 'Presenter T/E
receipt end
Public Const ASB_PRESENTER_TT As Long = &H2000000 'Presenter T/T
receipt end
Public Const ASB_RETRACTOR_R1JAM As Long = &H4000000 'Presenter
receipt end R1JAM
Public Const ASB_RETRACTOR_BOX As Long = &H8000000 'Retractor box
Public Const ASB_RETRACTOR_R2JAM As Long = &H20000000 'Retractor
receipt end R2JAM
Public Const ASB_RETRACTOR_SENSOR3 As Long = &H40000000 'Receipt end
retractor box

Public Const ASB_BATTERY_OFFLINE As Long = &H4 'Off-line for
BATTERY QUANTITY (3.01)
Public Const ASB_PAPER_FEED As Long = &H40 'Paper
is now feeding by PF FW (3.01)
Public Const ASB_PAPER_END_FIRST As Long = &H40000 'Detected paper
roll end first (3.01)
Public Const ASB_PAPER_END_SECOND As Long = &H80000 'Detected paper
roll end second (3.01)

Public Const PIXELS = 3
Public Const TWIPS = 1

'Battery Status
Public Const POWER_AC_ST = &H30
Public Const POWER_BT_ST = &H31

Public Const BATTERY_ST_H = &H30
Public Const BATTERY_ST_M = &H31
Public Const BATTERY_ST_L = &H32
Public Const BATTERY_ST_S = &H33
Public Const BATTERY_ST_N = &H34

'OS Version
Public iIsNT As Integer
Public Const VER_ISNT = 2

'Font Lists
Public Const LF_FACESIZE = 32
Public Const LF_FULLFACESIZE = 64

' ntmFlags field flag
Public Const NTM_REGULAR = &H40&
Public Const NTM_BOLD = &H20&
Public Const NTM_ITALIC = &H1&

' tmPitchAndFamily flag
Public Const TMPF_FIXED_PITCH = &H1
Public Const TMPF_VECTOR = &H2
Public Const TMPF_DEVICE = &H8
Public Const TMPF_TRUETYPE = &H4

Public Const ELF_VERSION = 0
Public Const ELF_CULTURE_LATIN = 0

' EnumFonts mask
Public Const RASTER_FONTTYPE = &H1
Public Const DEVICE_FONTTYPE = &H2
Public Const TRUETYPE_FONTTYPE = &H4

' RegOpenKeyEx
Public Const HKEY_LOCAL_MACHINE = &H80000002
Public Const KEY_QUERY_VALUE = &H1

' RegQueryValueEx
Public Const REG_SZ = 1 ' Unicode nul terminated
string
Public Const READ_CONTROL = &H20000
Public Const STANDARD_RIGHTS_READ = (READ_CONTROL)
Public Const KEY_ENUMERATE_SUB_KEYS = &H8
Public Const KEY_NOTIFY = &H10
Public Const SYNCHRONIZE = &H100000
Public Const STANDARD_RIGHTS_ALL = &H1F0000
Public Const KEY_SET_VALUE = &H2
Public Const KEY_CREATE_SUB_KEY = &H4
Public Const KEY_CREATE_LINK = &H20