on 04-12-2006 8:24 AM
Hi,
I created a program that open the BP Master Data form with FORM_LOAD (ItemEvent) and add a combobox on it.
When I write the ValidValues of this combobox in the code, it works perfectly.
But when I try to insert the ValidValues with the result of a query, it doesn't work...
Is it possible to do queries inside an ItemEvent ?
Thank you !
Thibault
Hello,
What is the error that you get ?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello,
Here is my code
Friend Class AutrePartenaire
Private WithEvents SBO_Application As SAPbouiCOM.Application
Private SboGuiApi As SAPbouiCOM.SboGuiApi
Private oCompany As SAPbobsCOM.Company
Private oRecord As SAPbobsCOM.Recordset
Private oDBDatabase As SAPbouiCOM.DBDataSource
Private oForm As SAPbouiCOM.Form
Private oItem As SAPbouiCOM.Item
Private oCombo As SAPbouiCOM.ComboBox
Private i As Integer
Private Sub CreationApplication()
Try
SboGuiApi = New SAPbouiCOM.SboGuiApi
SboGuiApi.Connect(Environment.GetCommandLineArgs.GetValue(1))
SBO_Application = SboGuiApi.GetApplication()
Catch
SBO_Application.MessageBox(Err.Description)
End Try
End Sub
Private Sub ConnectionSociete()
Dim sCookie As String
Dim sCookieContext As String
Try
oCompany = New SAPbobsCOM.Company
sCookie = oCompany.GetContextCookie
sCookieContext = SBO_Application.Company.GetConnectionContext(sCookie)
oCompany.SetSboLoginContext(sCookieContext)
If (oCompany.Connect() <> 0) Then
SBO_Application.MessageBox("Erreur durant la connection à la base de données!")
Exit Sub
End If
Catch
SBO_Application.MessageBox(Err.Description)
End Try
End Sub
Private Sub SBO_Application_ItemEvent(ByVal FormUID As String, ByRef pVal As SAPbouiCOM.ItemEvent, ByRef BubbleEvent As Boolean) Handles SBO_Application.ItemEvent
If (pVal.EventType = SAPbouiCOM.BoEventTypes.et_FORM_LOAD And pVal.BeforeAction = False) Then
If pVal.FormType = 134 Then
AjoutComboATypePart()
End If
End If
End Sub
Private Sub AjoutComboATypePart()
Try
For i = 0 To SBO_Application.Forms.Count - 1
oForm = SBO_Application.Forms.Item(i)
If (oForm.TypeEx = 134) Then
oForm.Freeze(True)
oItem = oForm.Items.Add("Combo", SAPbouiCOM.BoFormItemTypes.it_COMBO_BOX)
oItem.Left = 283
oItem.Top = 7
oItem.Height = 14
oItem.DisplayDesc = True
oCombo = oItem.Specific
oRecord = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset)
oRecord.DoQuery("SELECT Code, Name FROM [@ATPA] ORDER BY Code")
oRecord.MoveFirst()
While Not (oRecord.EoF)
oCombo.ValidValues.Add(oRecord.Fields.Item("Code").Value, oRecord.Fields.Item("Name").Value)
oRecord.MoveNext()
End While
oForm.Freeze(False)
End If
Next
oDBDatabase = oForm.DataSources.DBDataSources.Add("OCRD")
oCombo.DataBind.SetBound(True, "OCRD", "U_CTypePart")
Catch
SBO_Application.MessageBox(Err.Description)
End Try
End Sub
Private Sub SBO_Application_AppEvent(ByVal EventType As SAPbouiCOM.BoAppEventTypes) Handles SBO_Application.AppEvent
Try
If (EventType = SAPbouiCOM.BoAppEventTypes.aet_ShutDown) Then
System.Windows.Forms.Application.Exit()
End If
Catch
SBO_Application.MessageBox(Err.Description)
End Try
End Sub
Public Sub New()
MyBase.New()
CreationApplication()
ConnectionSociete()
End Sub
End Class
And I have the error :
QueryInterface error for SAPbobsCOM.ICompany interface...
Thanks !
Hi Thibault,
It is possible to do a query inside an itemevent.
Can you post your code, so we can take a look at it and what error do you get?
Regards
Ad
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
108 | |
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.