afarinpour
IS-IT--Management
I'm working with MAS90 ver9.0 (not the SQL version) and am trying to pull data from three tables use the data to populate a Excel Worksheet. Below is the code I am using;
Private Sub cmdForcast2005_Click()
'Variable settings
Dim ws As Workspace
Dim MAS90db As DAO.Database
Dim MAS90im As DAO.Recordset
Dim MAS90arn As DAO.Recordset
Dim MAS90aro As DAO.Recordset
Dim sqlIM As String
Dim sqlARN As String
Dim sqlARO As String
'Create a default workspace Object
Set ws = CreateWorkspace("", "", "", dbUseODBC)
'Create a Database object
Set MAS90db = ws.OpenDatabase("ODBC;DSN=SOTAMAS90;Company='Valrhona(001)';UID='arya';password='hunter'")
'Create a Recordset object
'ARN table - holds invoice information
sqlARN = "SELECT * FROM ARN_InvHistoryHeader"
Set MAS90arn = MAS90db.OpenRecordset(sqlARN)
'ARO table - holds invoice detail
sqlARO = "SELECT * FROM ARO_InvHistoryDetail"
Set MAS90aro = MAS90db.OpenRecordset(sqlARO)
'IM Master Table - holds item weight
sqlIM = "SELECT * FROM IM_90_UDF_IMMasterfile"
Set MAS90im = MAS90db.OpenRecordset(sqlIM)
For i = 6 To 20
loc1 = "D" & i
loc2 = "C" & i
Range(loc1).Value = MAS90im!Weight
Range(loc2).Value = MAS90im!ItemNumber
MAS90im.MoveNext
Next i
End Sub
Whan I run the code I get a Run-Time error '3146' ODBC call faild. Code stops at the MAS90im.MoveNext.....
Anyone have an idea as to why this is happening?..thanks
Arya
Private Sub cmdForcast2005_Click()
'Variable settings
Dim ws As Workspace
Dim MAS90db As DAO.Database
Dim MAS90im As DAO.Recordset
Dim MAS90arn As DAO.Recordset
Dim MAS90aro As DAO.Recordset
Dim sqlIM As String
Dim sqlARN As String
Dim sqlARO As String
'Create a default workspace Object
Set ws = CreateWorkspace("", "", "", dbUseODBC)
'Create a Database object
Set MAS90db = ws.OpenDatabase("ODBC;DSN=SOTAMAS90;Company='Valrhona(001)';UID='arya';password='hunter'")
'Create a Recordset object
'ARN table - holds invoice information
sqlARN = "SELECT * FROM ARN_InvHistoryHeader"
Set MAS90arn = MAS90db.OpenRecordset(sqlARN)
'ARO table - holds invoice detail
sqlARO = "SELECT * FROM ARO_InvHistoryDetail"
Set MAS90aro = MAS90db.OpenRecordset(sqlARO)
'IM Master Table - holds item weight
sqlIM = "SELECT * FROM IM_90_UDF_IMMasterfile"
Set MAS90im = MAS90db.OpenRecordset(sqlIM)
For i = 6 To 20
loc1 = "D" & i
loc2 = "C" & i
Range(loc1).Value = MAS90im!Weight
Range(loc2).Value = MAS90im!ItemNumber
MAS90im.MoveNext
Next i
End Sub
Whan I run the code I get a Run-Time error '3146' ODBC call faild. Code stops at the MAS90im.MoveNext.....
Anyone have an idea as to why this is happening?..thanks
Arya