Hey Paul,
Okay got it working.
First step
Open Notepad
Copy and paste the following
Quote:<job>
<runtime>
<description>Gets Data from a Record in an Access 2007 Database</description>
<named name="File" helpstring="File path of the ACCDB file" type="string" required="true" />
<named name="Query" helpstring="Table Name in Access" type="string" required="true" />
<named name="Password" helpstring="Password for Access Database" type="string" required="true" />
</runtime>
<scrit language="VBScript">
Set CN = CreateObject("ADODB.Connection")
Set RS = CreateObject("ADODB.RecordSet")
Set objArgs = WScript.Arguments
strFileName = objArgs(0)
strPassword = objArgs(2)
CN.Mode = adModeShareDenyNone
CN.Open "Provider=Microsoft.ACE.OLEDB.12.0;Data source=" & strFileName & ";Jet OLEDB:Database Password=" & strPassword
strQuery = objArgs(1)
RS.Open strQuery, cn, 3, 3
RS.MoveFirst
intFieldCnt = RS.Fields.Count-1
intRecCnt = RS.RecordCount-1
For intRecLoop = 0 to intRecCnt
strRecord = ""
For intFieldLoop = 0 To intFieldCnt
strRecord = strRecord & RS.Fields(intFieldLoop).Value & "|"
Next
WScript.StdOut.Write(strRecord)
WScript.StdOut.WriteBlankLines(1)
RS.MoveNext
Next
RS.Close
CN.Close
Set RS = Nothing
Set CN = Nothing
</scrit>
</job>
Replace the word scrit with script(Had to change it in order to post it, line 8 and line 39)
Click File->Save As
Change Save As Type: to "All Files"
In File name: enter "C:\Sesame2\GetDataFromAccess.wsf", without the quotes.
Click Save
Close Notepad
Okay now in Sesame Designer, Go ahead and add a command Button named something that describes that it's going to get Data from Access.
Go into the On Element Entry event of that command button
Put the following code
Var vScriptPath as String
Var vAccessFilePath as String
Var vQuery as String
Var vReturn as String
Var vPos as Int
vScriptPath = "C:\Sesame2\GetDataFromAccess.wsf"
vAccessFilePath = "C:\MyAccessFile.mdb"
vQuery = "Select [Elastomer History].[FieldOne], [Elastomer History].[FieldTwo] FROM [Elastomer History] WHERE ((([Elastomer History].[Lot Number])='" + LotNumberElement + "') AND (([Elastomer History].[Base Material Number])='" + BaseMaterialElement + "'));"
vReturn = @RedirectProcess("cscript """ + vScriptPath + """ """ + vAccessFilePath + """ """ + vQuery + """ ""chemist""", "")
If vReturn <> "" Then
{
vPos = @InStr(vReturn, @Chr(10) + @Chr(13) + @Chr(10))
vReturn = @Right(vReturn, @Len(vReturn) - vPos - 2)
ElementOne = Split(vReturn, "|")
ElementTwo = Split(vReturn, "|")
}
You will need to replace the following parts with your actual names.
C:\MyAccessFile.mdb = The actual path to your mdb file
FieldOne = The name of First Field in the Access Table you want Data from
FieldTwo = The name of Second Field in the Access Table you want Data from
LotNumberElement = The name of the Element on your Sesame form that contains the Lot Number
BaseMaterialElement = The name of the Element on your Sesame form that contains the Base Material Number
ElementOne = The name of the First element on your Form in Sesame that you want the data from FieldOne in Access to go
ElementTwo = The name of the Second element on your Form in Sesame that you want the data from FieldTwo in Access to go
For more than two elements just modify the vQuery line(If you want you can create the query in Access 2007, go to SQL view and then just copy the Select part), and then copy the line with Split() in it for each new element.
I think that's everything. Now I'm going to go enjoy my evening knowing that I do not have to look at Access for the rest of the day

-Ray