Page Index Toggle Pages: [1] 2  Send Topic Send Topic Print Print
Hot Topic (More than 10 Replies) Get info from Microsoft Access (Read 3622 times)
NHUser
Full Member
***
Offline



Posts: 320
Location: Amherst, NH
Joined: Aug 2nd, 2010
Get info from Microsoft Access
Jul 18th, 2012 at 8:07pm
Print Post Print Post  
I have a legacy Access database that is still being used.  I would like to have Sesame look up some information from the Access database.  In other words, can I be in Sesame and enter a lot number and have Sesame automatically look in the Access database and pull some data from Access into another element in Sesame?
« Last Edit: Jul 19th, 2012 at 2:57pm by The Cow »  
Back to top
 
IP Logged
 
Ray the Reaper
Global Moderator
Members
Lantica Support
*****
Offline


The One & The Only

Posts: 2480
Joined: Aug 20th, 2003
Re: GET INFO FROM MICROSOFT ACCESS
Reply #1 - Jul 18th, 2012 at 8:25pm
Print Post Print Post  
Hello NHUser,

What version of Access is it? I may be able to come up with a script file to have access export that record out to CSV and we could parse that text file.

-Ray
  

Raymond Yoxall Consulting
ray.yoxall@gmail.com
ryoxall@lantica.com
Sesame Applications, Design and Support
Back to top
IP Logged
 
NHUser
Full Member
***
Offline



Posts: 320
Location: Amherst, NH
Joined: Aug 2nd, 2010
Re: GET INFO FROM MICROSOFT ACCESS
Reply #2 - Jul 19th, 2012 at 2:01pm
Print Post Print Post  
It's Access 2007.  Just to be clear, I know I could move all the data from the Access file to Sesame by downloading the file to a .csv file and then uploading into Sesame. 

That would require that I create a database to put all the Access data, which I'm trying to avoid.  Doing so would take more time than I want to invest.

I was hoping I could get the Access info "as needed" from my application in Sesame.

If what I'm asking is not possible let me ask another question.  Is it possible to have Sesame upload a .csv file automatically when the user enters a certain form?  Or can sesame create a temporary list from a csv file and then use that list to "look up" a value?
  
Back to top
 
IP Logged
 
The Cow
YaBB Administrator
*****
Offline



Posts: 2530
Joined: Nov 22nd, 2002
Re: GET INFO FROM MICROSOFT ACCESS
Reply #3 - Jul 19th, 2012 at 2:56pm
Print Post Print Post  
Just about anything is possible. Its really just a question of how difficult or complicated MS will make it.
  

Mark Lasersohn&&Programmer&&Lantica Software, LLC
Back to top
IP Logged
 
NHUser
Full Member
***
Offline



Posts: 320
Location: Amherst, NH
Joined: Aug 2nd, 2010
Re: GET INFO FROM MICROSOFT ACCESS
Reply #4 - Jul 19th, 2012 at 2:58pm
Print Post Print Post  
So, which possibility seems the most likely to succeed, and how do I do it?
  
Back to top
 
IP Logged
 
Hammer
YaBB Administrator
Lanticans
*****
Offline


Fire bad. Tree pretty.

Posts: 3436
Location: Ohio
Joined: Nov 22nd, 2002
Re: GET INFO FROM MICROSOFT ACCESS
Reply #5 - Jul 19th, 2012 at 2:59pm
Print Post Print Post  
NHUser wrote on Jul 19th, 2012 at 2:58pm:
So, which possibility seems the most likely to succeed, and how do I do it?


Just hang on for a bit. Support is looking at a script for you.
  

- Hammer
The plural of anecdote is not data.
Back to top
IP Logged
 
Ray the Reaper
Global Moderator
Members
Lantica Support
*****
Offline


The One & The Only

Posts: 2480
Joined: Aug 20th, 2003
Re: Get info from Microsoft Access
Reply #6 - Jul 19th, 2012 at 3:29pm
Print Post Print Post  
Couple more questions for you NHUser:

Does the Access database have security on it?
What is the Table name in the Access Database that you want the data from?

-Ray
  

Raymond Yoxall Consulting
ray.yoxall@gmail.com
ryoxall@lantica.com
Sesame Applications, Design and Support
Back to top
IP Logged
 
NHUser
Full Member
***
Offline



Posts: 320
Location: Amherst, NH
Joined: Aug 2nd, 2010
Re: Get info from Microsoft Access
Reply #7 - Jul 19th, 2012 at 4:01pm
Print Post Print Post  
The database has a password "chemist" to open it.

The table is named "Elastomer History".

I want to be able to match two columns, "Lot Number" and "Base Material Number" and then select data from several other columns.
  
Back to top
 
IP Logged
 
Ray the Reaper
Global Moderator
Members
Lantica Support
*****
Offline


The One & The Only

Posts: 2480
Joined: Aug 20th, 2003
Re: Get info from Microsoft Access
Reply #8 - Jul 19th, 2012 at 6:07pm
Print Post Print Post  
.mdb file extension or was it created in Access 2007 or converted so it has the .accdb file extension?

-Ray
  

Raymond Yoxall Consulting
ray.yoxall@gmail.com
ryoxall@lantica.com
Sesame Applications, Design and Support
Back to top
IP Logged
 
NHUser
Full Member
***
Offline



Posts: 320
Location: Amherst, NH
Joined: Aug 2nd, 2010
Re: Get info from Microsoft Access
Reply #9 - Jul 19th, 2012 at 6:12pm
Print Post Print Post  
Its a .mdb extension.
  
Back to top
 
IP Logged
 
Ray the Reaper
Global Moderator
Members
Lantica Support
*****
Offline


The One & The Only

Posts: 2480
Joined: Aug 20th, 2003
Re: Get info from Microsoft Access
Reply #10 - Jul 19th, 2012 at 8:55pm
Print Post Print Post  
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
Code
Select All
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  Grin

-Ray
  

Raymond Yoxall Consulting
ray.yoxall@gmail.com
ryoxall@lantica.com
Sesame Applications, Design and Support
Back to top
IP Logged
 
Ray the Reaper
Global Moderator
Members
Lantica Support
*****
Offline


The One & The Only

Posts: 2480
Joined: Aug 20th, 2003
Re: Get info from Microsoft Access
Reply #11 - Jul 19th, 2012 at 9:07pm
Print Post Print Post  
One thing I should note, is that this will only work on systems that have Access 2007 installed on them. The wsf file would need to be tweaked for other version of Access.

-Ray
  

Raymond Yoxall Consulting
ray.yoxall@gmail.com
ryoxall@lantica.com
Sesame Applications, Design and Support
Back to top
IP Logged
 
NHUser
Full Member
***
Offline



Posts: 320
Location: Amherst, NH
Joined: Aug 2nd, 2010
Re: Get info from Microsoft Access
Reply #12 - Jul 23rd, 2012 at 6:52pm
Print Post Print Post  
It's working great!!  Doing just what I need it to do!
  
Back to top
 
IP Logged
 
NHUser
Full Member
***
Offline



Posts: 320
Location: Amherst, NH
Joined: Aug 2nd, 2010
Re: Get info from Microsoft Access
Reply #13 - Jul 24th, 2012 at 6:53pm
Print Post Print Post  
Hey, Ray

I find that there is a delay of 5-10 seconds when I click on the command button to start the programming you gave me.  I also noted that there is no indication that Sesame is working on getting the data (no hourglass, for example).

I've tried adding a dummy command button with a "getting data" note on it, but the visibility command doesn't seem to work.  I added the first visibility command to make the command button appear just above the line

vScriptPath = "C:\Sesame2\GetDataFromAccess.wsf"

in the programming above and then another command at the end.

But the command button never appears. 

Is there some other way to let the operator know that they command is processing?
  
Back to top
 
IP Logged
 
Ray the Reaper
Global Moderator
Members
Lantica Support
*****
Offline


The One & The Only

Posts: 2480
Joined: Aug 20th, 2003
Re: Get info from Microsoft Access
Reply #14 - Jul 25th, 2012 at 1:31pm
Print Post Print Post  
Try adding a ForceRedraw() call after your visibility call to force Sesame to redraw the screen with that element now visible. 2.5.3 will make this easier as it has a command to set the mouse pointer to an hourglass symbol and then back again.

-Ray
  

Raymond Yoxall Consulting
ray.yoxall@gmail.com
ryoxall@lantica.com
Sesame Applications, Design and Support
Back to top
IP Logged
 
Page Index Toggle Pages: [1] 2 
Send Topic Send Topic Print Print