I am using Adobe Acrobat ADBC to populate a pdf form from data in a MS Access db. Below are snippets of codes I have found on another website so far, and it works great, but our Customer Service Reps would like a display of what record they are looking at and the total number of records retrived. Plus while I'm at it how about a previous record control to go with the first record and next record controls (read that as buttons) that I already have.
I am really getting frustrated so any help at this time would be great!
// ADBC Globals
var dbName = "FIS";
var dbConn = null;
var stmtObj = null;
var sqlToExecute = 'Select * from "Enrollment Form"';
var rowObj = null;
function Startup()
{
}
// Connect to DataBase
function Connect()
{
try
{
app.alert("Attempting Connection ...");
dbConn = ADBC.newConnection(dbName);
if(dbConn == null)
throw "Error connecting to FIS";
stmtObj = dbConn.newStatement();
stmtObj.execute(sqlToExecute); // Execute the SQL statement inside the database
stmtObj.nextRow(); // Move the Result Set to the First Record Found
rowObj = stmtObj.getRow(); // The current row object
FillForm(rowObj); // Insert the values of the first Row of data into the form field values.
app.alert("Connected to FIS"); // Let the user know that a connection was made.
}
catch(exc)
{
console.println(exc);
throw "Unable to Connect to Database";
}
}
function firstRecord()
{
stmtObj.execute(sqlToExecute);
stmtObj.nextRow();
rowObj = stmtObj.getRow();
FillForm(rowObj);
}
function nextRecord()
{
try
{
stmtObj.nextRow();
FillForm(stmtObj.getRow());
}
catch(e)
{
}
}
function FillForm(row)
{
this.getField("ee.name.first").value = row.FirstName.value;
this.getField("ee.name.mi").value = row.MiddleInit.value;
this.getField("ee.name.last").value = row.LastName.value;
this.getField("ee.address.street").value = row.tbl_ClInsured_Address.value;
this.getField("ee.address.city").value = row.tbl_ClInsured_City.value;
this.getField("ee.address.state").value = row.State.value;
this.getField("ee.address.zip").value = row.Zip.value;
this.getField("ee.ssn").value = row.SSN.value;
this.getField("ee.phone.home").value = row["Home Phone"].value;
}
I am really getting frustrated so any help at this time would be great!
// ADBC Globals
var dbName = "FIS";
var dbConn = null;
var stmtObj = null;
var sqlToExecute = 'Select * from "Enrollment Form"';
var rowObj = null;
function Startup()
{
}
// Connect to DataBase
function Connect()
{
try
{
app.alert("Attempting Connection ...");
dbConn = ADBC.newConnection(dbName);
if(dbConn == null)
throw "Error connecting to FIS";
stmtObj = dbConn.newStatement();
stmtObj.execute(sqlToExecute); // Execute the SQL statement inside the database
stmtObj.nextRow(); // Move the Result Set to the First Record Found
rowObj = stmtObj.getRow(); // The current row object
FillForm(rowObj); // Insert the values of the first Row of data into the form field values.
app.alert("Connected to FIS"); // Let the user know that a connection was made.
}
catch(exc)
{
console.println(exc);
throw "Unable to Connect to Database";
}
}
function firstRecord()
{
stmtObj.execute(sqlToExecute);
stmtObj.nextRow();
rowObj = stmtObj.getRow();
FillForm(rowObj);
}
function nextRecord()
{
try
{
stmtObj.nextRow();
FillForm(stmtObj.getRow());
}
catch(e)
{
}
}
function FillForm(row)
{
this.getField("ee.name.first").value = row.FirstName.value;
this.getField("ee.name.mi").value = row.MiddleInit.value;
this.getField("ee.name.last").value = row.LastName.value;
this.getField("ee.address.street").value = row.tbl_ClInsured_Address.value;
this.getField("ee.address.city").value = row.tbl_ClInsured_City.value;
this.getField("ee.address.state").value = row.State.value;
this.getField("ee.address.zip").value = row.Zip.value;
this.getField("ee.ssn").value = row.SSN.value;
this.getField("ee.phone.home").value = row["Home Phone"].value;
}