Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Connecting Extra Macro to a MS Access DB 1

Status
Not open for further replies.

welshtroll

Programmer
Nov 29, 2001
55
GB
I'm building an automated keying macro.
But i'm having problem connecting the macro to a MS access database to retrieve the database.

Any suggestions???

Cheers
K
 
You can use ADO or DAO to do this.
You can only dim the objects as object and not as ADODB.recordset

Dim adoConn as object
Dim adoRS as object
Dim strConString as string
Dim strSQL as string
strConString ="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\MyDB.mdb;"

Set adoConn = createobject("ADODB.CONNECTION")

adoConn.open strConString
strSQL = "Select * from MyTable"
adoRS.open strSQL, adoconn

do
adoRS.addnew
adoRS.fields("acctnum").value = Sess0.Screen.getstring(1,1,11)
Sess0.Screen.Sendkeys(&quot;<Enter>&quot;)
Sess0.Screen.WaitHostQuiet(100)
loop until Sess0.Screen.getstring(1,1,11) = &quot;End of File&quot;

adoRS.close
adoConn.close
Set adoRS = nothing
Set adoConn = nothing
'You should write error handling to set the ado objects to nothing
'I did not test this code but it is very close to a working model
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top