irenavassilia
Programmer
- Jun 19, 2007
- 101
Hi Everyone,
I have a function which is suppose to get the manufacturing item number under the specified item, but my fetch is always false, this is no brainer im sure, i just have little time to figure this out and im running out of ideas, here is my code:
Sub Main(ByRef strManfItem As String)
'Declare variables here
Dim rs As AccpacCOMAPI.AccpacView
Dim DBLinkCmpRW As AccpacCOMAPI.AccpacDBLink
Dim Session As New AccpacSession
Dim strFilter As String
On Error GoTo ACCPACErrorHandler ' Set error handler
Session.Init "", "IC", "IC1140", "54A"
Session.Open "ADMIN", "ADMIN", "SAMLTD", Date, 0, 0
'Open dblink
Set DBLinkCmpRW = Session.OpenDBLink(DBLINK_COMPANY, DBLINK_FLG_READWRITE)
'Open view
DBLinkCmpRW.OpenView "IC0305", rs
'Your code is here
With rs
.Init
strFilter = "(ITEMNO = " + strManfItem + ")"
.Browse strFilter, True
Do While .Fetch
strManfItem = .Fields("MANITEMNO")
Loop
.Close
Set rs = Nothing
End With
'Cleanup
Set DBLinkCmpRW = Nothing
Exit Sub
ACCPACErrorHandler:
Dim lCount As Long
Dim lIndex As Long
If Errors Is Nothing Then
'MsgBox Err.Description
Else
lCount = Errors.Count
If lCount = 0 Then
MsgBox Err.Description
Else
For lIndex = 0 To lCount - 1
MsgBox Errors.Item(lIndex)
Next
Errors.Clear
End If
Resume Next
End If
End Sub
ANY HELP WOULD BE GREATFUL.
THANK YOU.
I have a function which is suppose to get the manufacturing item number under the specified item, but my fetch is always false, this is no brainer im sure, i just have little time to figure this out and im running out of ideas, here is my code:
Sub Main(ByRef strManfItem As String)
'Declare variables here
Dim rs As AccpacCOMAPI.AccpacView
Dim DBLinkCmpRW As AccpacCOMAPI.AccpacDBLink
Dim Session As New AccpacSession
Dim strFilter As String
On Error GoTo ACCPACErrorHandler ' Set error handler
Session.Init "", "IC", "IC1140", "54A"
Session.Open "ADMIN", "ADMIN", "SAMLTD", Date, 0, 0
'Open dblink
Set DBLinkCmpRW = Session.OpenDBLink(DBLINK_COMPANY, DBLINK_FLG_READWRITE)
'Open view
DBLinkCmpRW.OpenView "IC0305", rs
'Your code is here
With rs
.Init
strFilter = "(ITEMNO = " + strManfItem + ")"
.Browse strFilter, True
Do While .Fetch
strManfItem = .Fields("MANITEMNO")
Loop
.Close
Set rs = Nothing
End With
'Cleanup
Set DBLinkCmpRW = Nothing
Exit Sub
ACCPACErrorHandler:
Dim lCount As Long
Dim lIndex As Long
If Errors Is Nothing Then
'MsgBox Err.Description
Else
lCount = Errors.Count
If lCount = 0 Then
MsgBox Err.Description
Else
For lIndex = 0 To lCount - 1
MsgBox Errors.Item(lIndex)
Next
Errors.Clear
End If
Resume Next
End If
End Sub
ANY HELP WOULD BE GREATFUL.
THANK YOU.