on 09-24-2008 9:33 AM
I try to fill-in a matrix using a recordset and userdatasource.
here is a part of codes:
For i As Integer = 1 To rs.RecordCount
oMatrix.AddRow(i)
oUDSCardCode.ValueEx = rs.Fields.Item("CardCode").Value
oUDSCardName.ValueEx = rs.Fields.Item("CardName").Value
oUDSItemCode.ValueEx = rs.Fields.Item("ItemCode").Value
oUDSItemName.ValueEx = rs.Fields.Item("ItemName").Value
oMatrix.SetLineData(i)
oMatrix.FlushToDataSource()
rs.MoveNext()
Next i
my problem is, there is only 3 records in the recordset:
i.e.
AAACode AAAName AAAItem AAADesc
BBBCode BBBName BBBItem BBBDesc
CCCCode CCCName CCCItem CCCDesc
but the Matrix shows:
AAACode AAAName AAAItem AAADesc
BBBCode BBBName BBBItem BBBDesc
BBBCode BBBName BBBItem BBBDesc
CCCCode CCCName CCCItem CCCDesc
CCCCode CCCName CCCItem CCCDesc
CCCCode CCCName CCCItem CCCDesc
Any ideas?
Thanks
Hi,
the mistake is that you use
oMatrix.AddRow(i)
that means you add 3 lines when i = 3
better add the row with
oMatrix.AddRow(1, -1)
lg David
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi
This is code used to add rows to matrix from RS.
Hope its help you.
Regards
Sierdna S.
Dim sSql As String = ""
sSql = "SELECT DocNum,.. FROM ... WHERE ..."
oRS = SBO_Company.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset)
oRS.DoQuery(sSql)
If oRS.RecordCount > 0 Then
Dim i As Integer = 0
oRS.MoveFirst()
While oRS.EoF = False
i = i + 1
oForm.DataSources.UserDataSources.Item("uNr").Value = i ' 1" matrix column for row number
oForm.DataSources.UserDataSources.Item("uChoise").Value = "1" ' For user choise checkbox column
oForm.DataSources.UserDataSources.Item("uDocNum").Value = oRS.Fields.Item("DocNum").Value
oForm.DataSources.UserDataSources.Item("uLineNum").Value = oRS.Fields.Item("LineNum").Value
oForm.DataSources.UserDataSources.Item("uItemCode").Value = oRS.Fields.Item("ItemCode").Value
oForm.DataSources.UserDataSources.Item("uItemName").Value = oRS.Fields.Item("ItemName").Value
oForm.DataSources.UserDataSources.Item("uQuantity").Value = oRS.Fields.Item("Quantity").Value
oForm.DataSources.UserDataSources.Item("uNotes").Value = oRS.Fields.Item("Notes").Value
' ++++++++++++++++++++
oMatrix.AddRow()
' ++++++++++++++++++++
oRS.MoveNext()
End While
End If
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi
Thanks For ur reply i did as u directed..
here is the code how i implement .
what i need to do is.. i have designed a form purchase indent from that using copy to functionality i have to store all the data from that form to purchase order form.
i am able to open the purchase order and load some values while load the matrix i faced a problem.
can u reffer the code and advise me where i committed mistake plz..
SBO_Application.ActivateMenuItem("2305")
Dim f As SAPbouiCOM.Form
f = SBO_Application.Forms.ActiveForm
'Dim f As SAPbouiCOM.Form
'f = SBO_Application.Forms.Item("142")
'f.Select()
' ' f.Execute() Dim f As SAPbouiCOM.Form
Dim oField As SAPbouiCOM.EditText
oItem = f.Items.Item("16")
oField = oItem.Specific
oField.String = "Based On PurchaseIndent:" + oForm.Items.Item("3").Specific.Value
Dim sSql As String = ""
Dim oRS As SAPbobsCOM.Recordset
oItem = f.Items.Item("38")
oMatrix = oItem.Specific
oColumns = oMatrix.Columns
sSql = "select a.U_ITEM as Code, a.U_DESC as Descp,a.U_QTY as Quantity,a.U_RATE as price from [@TBL_INDENTROWS1] a,[@TBL_INDENT1] b where a.DocEntry=b.DocEntry and b.U_INDNO='" & oForm.Items.Item("3").Specific.Value & " '"
oRS = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset)
oRS.DoQuery(sSql)
If oRS.RecordCount > 0 Then
Dim i As Integer = 0
oRS.MoveFirst()
While oRS.EoF = False
i = i + 1
oMatrix.Columns.Item("Column1").Cells.Item(i).Specific.Value = oRS.Fields.Item("Code").Value
oMatrix.Columns.Item("Column3").Cells.Item(i).Specific.Value = oRS.Fields.Item("Descp").Value
oMatrix.Columns.Item("Column11").Cells.Item(i).Specific.Value = oRS.Fields.Item("Quantity").Value
oMatrix.Columns.Item("Column13").Cells.Item(i).Specific.Value = oRS.Fields.Item("price").Value
oMatrix.AddRow()
oRS.MoveNext()
End While
End If
when the control reaches to column 1 it terminates and exception is followed .. plz reply m soon..
got it.
thank you very much.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
thanks for your reply.
i mean rs.Recordcount = 3
so i would expect it shows 3 rows in the Matrix,
but now i get totally 6 rows.
I've already added oMatrix.AddRow(i, -1), but problem stills.
Pls. adv.
Thanks
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
103 | |
12 | |
11 | |
6 | |
5 | |
4 | |
3 | |
3 | |
3 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.