Anthony,
Here is a class I created for VB6 to retrieve line item information for
a given order. I don't know about using any toolbox items but I do add
the resources to the project then create the object.
This class is actually used at my company to create a label that is
affixed to a product.
I hope you find some useful information here.
Jeff
On Sun, 2007-03-11 at 19:07 -0400, Anthony Dzikiewicz wrote:
> Hi guys,
>
> I am messing with Visual Basic Express edition. I was hoping to use
> UniObjects against my Universe Database. The examples in the UniObjects
> Developers Guide are a little outdated. How do I get the UniObjects to
> appear in the toolbar (if you can do this) ? They refer to Sub
> Form_Load, which I have seen in older versions of VB, but not VB 2005.
> Basically what I am looking for is a 'quick fix' for the 5 minute
> program example in the Developers Guide that has already taken me beyond
> that time frame.
>
> Thanks
> Anthony
>
VERSION 1.0 CLASS
BEGIN
MultiUse = -1 'True
Persistable = 0 'NotPersistable
DataBindingBehavior = 0 'vbNone
DataSourceBehavior = 0 'vbNone
MTSTransactionMode = 0 'NotAnMTSObject
END
Attribute VB_Name = "ud-access"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = False
Dim Uni As Object
Dim selList As UniSelectList
Dim dynArray As UniDynArray
Dim dynRec As Object
Dim ordFile As UniFile
Dim ordLineFile As UniFile
Dim relLineFile As UniFile
Dim custFile As UniFile
Dim catFile As UniFile
Dim prodFile As UniFile
Dim rs() As CLabelRecord
Public Sub GetRecords(stRefNum, Text1 As TextBox)
' On Error GoTo ErrorHandler
Set Uni = CreateObject(UV_SESSION_OBJECT)
Uni.AccountPath = "/ud/YOUR-LIVE-ACCOUNT"
Uni.HostName = "ud-server"
Uni.UserName = "user"
Uni.Password = "password"
' UniSession.DataBaseType = 2
iRecCount = 0
iReleaseMode = 0
' new flogic for scanner
' TUA00007$PT$F$1/2
iStringEnd = InStr(1, stRefNum, "$")
If iStringEnd > 0 Then
stRefNum = Mid(stRefNum, 1, iStringEnd - 1)
Text1.Text = stRefNum
Text1.Refresh
End If
If Uni.Connect = True Then
' If Staging.Value = 1 Then
If InStr(1, stRefNum, "-") = 0 Then
strSql = "SELECT ORDER.LINE WITH ORD.NUM=""" &
UCase(stRefNum) & """ BY ZONE.IPS BY SEQ.NUM TO 1"
Else
strSql = "SELECT RELEASE.LINE WITH RELEASE.NUM=""" &
UCase(stRefNum) & """ BY ZONE.IPS BY SEQ.NUM TO 1"
iReleaseMode = 1
End If
If Uni.IsActive Then
Set ordFile = Uni.OpenFile("ORDER")
If ordFile Is Nothing Then MsgBox "ORDER not open"
Set ordLineFile = Uni.OpenFile("ORDER.LINE")
If ordLineFile Is Nothing Then MsgBox "ORDER.LINE not open"
Set relLineFile = Uni.OpenFile("RELEASE.LINE")
If relLineFile Is Nothing Then MsgBox "RELEASE.LINE not
open"
Set custFile = Uni.OpenFile("CUSTOMER")
If custFile Is Nothing Then MsgBox "CUSTOMER not open"
Set catFile = Uni.OpenFile("CATEGORY")
If catFile Is Nothing Then MsgBox "CATEGORY not open"
Set prodFile = Uni.OpenFile("PRODUCT")
If prodFile Is Nothing Then MsgBox "PRODUCT not open"
' DoMsg "Looking up " + UCase(Text1.Text)
Uni.Command.Text = strSql
Uni.Command.Exec
' Build the recordset from records received
Set selList = Uni.SelectList(1)
Set dynArray = selList.ReadList ' List of records
ReDim rs(dynArray.Count)
For iLineItemLoop = 1 To dynArray.Count
Set rs(iLineItemLoop) = New CLabelRecord
LineKey = dynArray.Value(iLineItemLoop, 0)
OrderKey = Mid(LineKey, 1, 11)
OrderNum = Mid(LineKey, 4, 8)
If iReleaseMode = 1 Then
relLineFile.RecordId = LineKey
relLineFile.Read
LineKey = relLineFile.Record.Value(2, 0)
End If
ordLineFile.RecordId = LineKey
ordLineFile.Read
ordFile.RecordId = OrderKey
ordFile.Read
' Get information from the Order Header
rs(iLineItemLoop).CustPoNum = ordFile.Record.Value(12,
0) ' Customer PO Number
rs(iLineItemLoop).JobNum = ordFile.Record.Value(133, 0)
' Customer Job Number
rs(iLineItemLoop).OrderNum = OrderNum
rs(iLineItemLoop).RelNum = stRefNum
rs(iLineItemLoop).CustLnNum =
ordLineFile.Record.Value(92, 0)
rs(iLineItemLoop).CustProdNum =
ordLineFile.Record.Value(153, 0)
rs(iLineItemLoop).PckQty = ordLineFile.Record.Value(38,
0)
rs(iLineItemLoop).UnMeas = ordLineFile.Record.Value(103,
0)
rs(iLineItemLoop).ProdNum = ordLineFile.Record.Value(27,
0)
rs(iLineItemLoop).ProdDesc =
ordLineFile.Record.Value(28, 1)
iTagCount = ordLineFile.Record.Field(215).Count
If iTagCount = 0 Then
rs(iLineItemLoop).SetTagCount 1
rs(iLineItemLoop).SetTagInfo 1,
ordLineFile.Record.Value(215, 0)
Else
rs(iLineItemLoop).SetTagCount iTagCount
For Tag = 1 To iTagCount
rs(iLineItemLoop).SetTagInfo Tag,
ordLineFile.Record.Value(215, Tag)
Next Tag
End If
' Get product information (pline.num (attrib 3)
prodFile.RecordId = "100" + rs(iLineItemLoop).ProdNum
prodFile.Read
' Get major group from category
catFile.RecordId = "100" + prodFile.Record.Value(3, 0)
catFile.Read
rs(iLineItemLoop).MajorGrp = catFile.Record.Value(2, 0)
' Get Customer Name
rs(iLineItemLoop).CustNum = ordFile.Record.Value(1, 0)
' Order Attribute 1
custFile.RecordId = "100" + rs(iLineItemLoop).CustNum
custFile.Read
rs(iLineItemLoop).CustName = custFile.Record.Value(1, 0)
' Customer Attribute 1
Next iLineItemLoop
done:
Else
MsgBox "Unidata connection not active"
End If
Uni.Disconnect
Else
MsgBox Uni.Error, vbOKOnly, "Connection Failure"
End If
Exit Sub
ErrorHandler:
Uni.Disconnect
catch
End Sub
Public Function getRecordSet() As CLabelRecord()
getRecordSet = rs()
End Function
Public Sub catch()
MsgBox "Error # " & CStr(Err.Number) & " " & Err.Description
End Sub
Public Function getRowCount()
getRowCount = UBound(rs)
End Function
-------
u2-users mailing list
[email protected]
To unsubscribe please visit http://listserver.u2ug.org/