on 03-31-2006 10:12 AM
Hi,
Is it possible to create a ComboBox with the possibility to Define new values?
I tried to create a user-defined table with the values, but I don't know how to link this table to the ValidValues of the ComboBox I created.
Thank you again for your help
Thibault
Hi Thibault,
I have also thought about this previously. You can add a standard combo box to your window, but you will have to populate the values manually. Like this:
oRecord = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset)
oRecord.DoQuery("SELECT Code, Name FROM [@XXXX]")
oRecord.MoveFirst()
While Not oRecord.EoF
oCombo.ValidValues.Add(oRecord.Fields.Item("Code").Value, oRecord.Fields.Item("Name").Value)
oRecord.MoveNext()
End While
What you'll have to do then is add another entry that says define new. So your code will be:
oCombo.ValidValues.Add(" ", "Define New")
Then you'll have to check whether the last entry was selected and then show the UDF form. This you can do with this code:
Dim oMenu As SAPbouiCOM.MenuItem
Dim sVal As String
Dim sMenuUID As String
Dim s As String
Dim i As Integer
sVal = "MYTABLE"
Try
oMenu = oApplication.Menus.Item("51200")
For i = 0 To oMenu.SubMenus.Count - 1
If oMenu.SubMenus.Item(i).String.Length < sVal.Length Then
s = oMenu.SubMenus.Item(i).String
Else
s = oMenu.SubMenus.Item(i).String.Substring(0, sVal.Length)
If s.Compare(s, sVal, True) = 0 Then
sMenuUID = oMenu.SubMenus.Item(i).UID
End If
End If
Next
oApplication.ActivateMenuItem(sMenuUID)
Catch ex As Exception
oApplication.MessageBox(ex.Message)
End Try
I haven't tried this whole thing in total like this, but in theory it should work.
Hope it helps,
Adele
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Before you create instance for oRecordset, you must create a object for oCompany and you should connect to company database. I think following code snipet will be help for you
Private WithEvents SBO_Application As SAPbouiCOM.Application
Dim oCompany As SAPbobsCOM.Company
Dim oGUI As New SAPbouiCOM.SboGuiApi
Dim sCookie As String
Dim sCookieContext As String
Dim iError As Integer
Try
oGUI.Connect(Environment.GetCommandLineArgs.GetValue(1))'SDK Sample will help you to understand this line
SBO_Application = oGUI.GetApplication
oCompany = New SAPbobsCOM.Company
sCookie = oCompany.GetContextCookie
sCookieContext = SBO_Application.Company.GetConnectionContext(sCookie)
oCompany.SetSboLoginContext(sCookieContext)
If oCompany.Connect() <> 0 Then
Status = "Error While Connection To Company Database!"
Exit Sub
Else
Status = "Connection Established To Company !"
End If
Catch
Status = Err.Description
End Try
I hope this will be hlep for you
With Regards
B Ravi Shankar
User | Count |
---|---|
107 | |
12 | |
11 | |
6 | |
5 | |
4 | |
4 | |
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.