Hi All;

I have written a macro that creates an OE Order. It is based on Stephen Smith's Order Entry creation macro. It all works just fine. I am now building some error checking. I have a subroutine that checks that the inventory item is active and this works. I am now trying to verify that there is enough quantity on hand to fulfill the order. Below is my code. It seems to be working but the QTONHAND returned is 0 when it should not be.

Here is my CheckItem function code:

Function CheckItem(ItemNo As String, txtInputFile As String, iCnt As Integer) As Boolean

Dim temp As Boolean

' Item Master
mDBLinkCmpRW.OpenView "IC0310", ICITEM_T1header
Set ICITEM_T1headerFields = ICITEM_T1header.Fields

' Units
mDBLinkCmpRW.OpenView "IC0750", ICITEM_T1detail1
Set ICITEM_T1detail1Fields = ICITEM_T1detail1.Fields

' Taxes
mDBLinkCmpRW.OpenView "IC0330", ICITEM_T1detail2
Set ICITEM_T1detail2Fields = ICITEM_T1detail2.Fields

' Optional Fields
mDBLinkCmpRW.OpenView "IC0313", ICITEM_T1detail3
Set ICITEM_T1detail3Fields = ICITEM_T1detail3.Fields

' Vendor Item Numbers
mDBLinkCmpRW.OpenView "IC0340", ICITEM_T1detail4
Set ICITEM_T1detail4Fields = ICITEM_T1detail4.Fields

' Customer Item Numbers
mDBLinkCmpRW.OpenView "IC0319", ICITEM_T1detail5
Set ICITEM_T1detail5Fields = ICITEM_T1detail5.Fields

' Item Serial Optional Fields
mDBLinkCmpRW.OpenView "IC0314", ICITEM_T1detail6
Set ICITEM_T1detail6Fields = ICITEM_T1detail6.Fields

' Item Lot Optional Fields
mDBLinkCmpRW.OpenView "IC0312", ICITEM_T1detail7
Set ICITEM_T1detail7Fields = ICITEM_T1detail7.Fields

' Item Location Details
mDBLinkCmpRW.OpenView "IC0374", ICITEM_T1detail8
Set ICITEM_T1detail8Fields = ICITEM_T1detail8.Fields


ICITEM_T1header.Compose Array(ICITEM_T1detail1, ICITEM_T1detail2, ICITEM_T1detail4, Nothing, Nothing, Nothing, Nothing, ICITEM_T1detail3, ICITEM_T1detail5, ICITEM_T1detail6, ICITEM_T1detail7, ICITEM_T1detail8)
ICITEM_T1detail1.Compose Array(ICITEM_T1header)
ICITEM_T1detail2.Compose Array(ICITEM_T1header, Nothing, Nothing)
ICITEM_T1detail3.Compose Array(ICITEM_T1header)
ICITEM_T1detail4.Compose Array(ICITEM_T1header, Nothing, ICITEM_T1detail1)
ICITEM_T1detail5.Compose Array(ICITEM_T1header, Nothing, ICITEM_T1detail1)
ICITEM_T1detail6.Compose Array(ICITEM_T1header)
ICITEM_T1detail7.Compose Array(ICITEM_T1header)
ICITEM_T1detail8.Compose Array(ICITEM_T1header)

'Set the Index to use ORDNUMBER i.e. the 2nd index.
ICITEM_T1headerFields("ITEMNO").Value = ItemNo ' Unformatted Item Number

ICITEM_T1header.Read
temp = ICITEM_T1header.Exists

If temp Then
If Not (ICITEM_T1headerFields("INACTIVE")) Then
CheckItem = True
ICITEM_T1detail8Fields.FieldByName("ITEMNO").Value = ItemNo
ICITEM_T1detail8Fields.FieldByName("LOCATION").Value = "1"
ICITEM_T1detail8.Read
temp = ICITEM_T1detail8.Exists
Else
txtwrite.WriteLine UserName & "," & Now & "," & txtInputFile & "," & Trim(Str(iCnt)) & "," & ItemNo & " not active."
CheckItem = False
PostOrder = False
End If
Else
txtwrite.WriteLine UserName & "," & Now & "," & txtInputFile & "," & Trim(Str(iCnt)) & "," & ItemNo & " does not exist."
CheckItem = False
PostOrder = False
End If

Set ICITEM_T1header = Nothing
Set ICITEM_T1headerFields = Nothing
Set ICITEM_T1detail1 = Nothing
Set ICITEM_T1detail1Fields = Nothing
Set ICITEM_T1detail2 = Nothing
Set ICITEM_T1detail2Fields = Nothing
Set ICITEM_T1detail3 = Nothing
Set ICITEM_T1detail3Fields = Nothing
Set ICITEM_T1detail4 = Nothing
Set ICITEM_T1detail4Fields = Nothing
Set ICITEM_T1detail5 = Nothing
Set ICITEM_T1detail5Fields = Nothing
Set ICITEM_T1detail6 = Nothing
Set ICITEM_T1detail6Fields = Nothing
Set ICITEM_T1detail7 = Nothing
Set ICITEM_T1detail7Fields = Nothing


End Function

This code executes, but there the value in the QTONHAND field is 0 when I view in the debuggered.

I got the view IC0374 from OE ui info OE1100. I am using ".read" as opposed to a fetch as I know the location and item numbers.

Any help/guidance would be appreciated.

Thanks

Stephen