This document describes two example Access databases that use the USA ePay XCharge component with Access forms to perform transactions in the USA ePay gateway.
One example database uses the Active-X Com component (.dll), and the other uses the Active-X control (.ocx) version of the XCharge component.
The examples provided demonstrate only two ways to implement XCharge's functionality in Access. Some developers prefer not to use forms at all or even use other Office applications. How you implement XCharge's functionality in your project is entirely up to you.
Before running the Access examples, you must first make sure that your system meets the requirements of the USA ePay XCharge component, and install the latest version of the XCharge component (with documentation) by clicking here.
The example databases require Microsoft Access 2000 or newer. Even though the example file requires Access 2000, you can use the XCharge control in any Office product that supports Active-X.
Follow these steps to run the Access example forms:
From the Access examples folder open either:
Go to the “
Forms” section and double click on the “
frmMain” form.

When you double click on “
frmMain” a form similar to the following should open:

Enter the appropriate details for your desired transaction and click on the “Process” button to see the results of the transaction.
Follow these steps to view the code that runs when the form is executed:
Go to the “Forms” section and then right click on the “frmMain” object and choose “Design View” from the pop-up menu.
The “frmMain” form should now be open in design view. Right click on the “Process” button and choose “Properties”.
In the “
Properties” dialog choose the “
Event” tab and then click on the word “
[Event Procedure]” which is on the “
On Click” line. Finally, click on the ellipsis (three dots) button to open the
VBA code editor.
With the
VBA code editor open, you can examine all the code used in this project.
Syntax and descriptions of the various properties and methods available in the XCharge component can be found in the “XCharge Component Documentation” shortcut on your start menu and here.
To use the XCharge component in your own database you must first add a reference to the XCharge component.
Follow these steps to add the COM (.dll) version of the XCharge component to your database:
In the
VBA code editor choose the “
Tools” menu and click on the “
References” menu item.
Find and check “USAePay XCharge Component Version 2” on the list.
Click the “OK” button.
Create a new instance of the XCharge object with code similar to the following:
Follow these steps to add the control (.ocx) version of the XCharge component to your database:
Open a form, report, or data access page in design view.
Choose the “Insert” menu and click on “Active-X Control.”
From the list, choose “USAePayXCharge2.XCharge2.”
Click the “OK” button.
You should now see an icon (this is the control) with the USA ePay logo on your form, report, or data access page.
Right click the control and choose the “Properties” menu item.
Set the properties you want.
Just like ASP, VBA does not recognize Active-X enumerations. So if you want to use named values (XCharge1.Command=CommandType.cvoid), instead of numbers (XCharge1.Command=2), you must include a module in your project that contains the following enumeration values:
Public Enum CommandType
sale = 0
credit = 1
cvoid = 2
authonly = 3
capture = 4
postauth = 5
check = 6
checkcredit = 7
End Enum
Public Enum ScheduleType
daily = 0
weekly = 1
biweekly = 2
monthly = 3
bimonthly = 4
quarterly = 5
annually = 6
biannually = 7
End Enum
Public Enum StatusType
Approved = 0
Declined = 1
Verification = 2
Error = 3
End Enum
Public Enum CptTermTypeType
pos = 0
StandAlone = 1
Unattended = 2
TermTypeUnknown = 3
End Enum
Public Enum CptMagSupportType
MagSupportYes = 0
MagSupportNo = 1
MagSupportUnknown = 2
End Enum