How To activate Menu in OK and UPDATE mode - vb.net

I enabled some menu in right click event. The first time it works well. For example 'Add Row' menu is pressed, it adds row. Again I right click button, and it's not showing the menus which I enabled in right click event. I need to add row again and again.
How can I achieve this?
Private Sub SBO_Application_RightClickEvent(ByRef eventInfo As SAPbouiCOM.ContextMenuInfo, ByRef BubbleEvent As Boolean) Handles SBO_Application.RightClickEvent
Try
oForm = SBO_Application.Forms.Item("TRADING")
If (eventInfo.FormUID = "TRADING") Then
oCombo = oForm.Items.Item("1000002").Specific
Dim oMenus As SAPbouiCOM.Menus
oMenus = SBO_Application.Menus
oForm.EnableMenu("1287", True)
oForm.EnableMenu("1292", True)
oForm.EnableMenu("1293", True)
If (oCombo.Selected.Value = "Open") Then
oMenus.Item("1283").Enabled = True
Else
oMenus.Item("1283").Enabled = False
End If
End If
Catch ex As Exception
End Try
End Sub

based on the input that u gave with your post, there may be two chance of getting error.
for the first time u are adding the row perfectly but in next time it was not working.. so i think code was not perfectly handled. try to place the same code in before action false. and also try to catch the action result that u get at item event so that we can debug the issue clearly.
to enable the right click event menu we need to handle the right click menu options based on oform.mode Separately.
for example in purchase order screen we will get different menu in add more and find mode.

Related

VBA - Closing the Opened form by DblClick Event, closes the whole running code?

I have a userform and some textboxes, I created a DblClick event to open and fill the second form according to the text box data. The problem is when I close Userform4, the whole running forms disappear! Nothing happens when I close userform3. But still, the mouse pointer shows the round status, like it is running a code!
I tried to change the Query_Close event of the second form to hide, but no luck. Can you please help? There is no Cancel button the Second form.
Private Sub txt1_DblClick(ByVal Cancel As MSForms.ReturnBoolean)
If Txt1.Locked = True Then
With ThisWorkbook.Sheets("target").Range("a1")
UserForm4.TextBoxJob2 = Txt1.value
UserForm4.TextBoxBadgeNum2 = .Offset(RowNumber, 3)
UserForm4.ComboBoxAC2 = .Offset(RowNumber, 0)
UserForm4.Show
End With
Else
UserForm3.Show
End If
End Sub
Regards,
M

access make list field visible when clicking Button

In an access form, I try to make a list field visible when the fokus is on another textfield in which new data should be filled in. The backround is that one should know the last data inputs to create a new one.
As a first step I tried to make the list (liste91) visible when clicking on a button, but I failed using the following code.
Private Sub Befehl97_Click()
Forms!projects!liste91.SetFocus
Me.liste91.visible = True
End Sub
I get error in the line Me.list91
what is wrong?
thank you for your help!
You can't set focus to something not yet visible. Just switch the order:
Private Sub Befehl97_Click()
Me.liste91.visible = True
Me.liste91.SetFocus
End Sub

Adding new record in access 2010

I want to enable a few fields when i click on the Add button on my form.I have change the onclick to Event Procedure to be able to add the following code
Category_Desc.Enabled = True
My Category field get enable as expected but the Add button no long work
Private Sub add_Click()
Category_Desc.Enabled = True
Me.Refresh
End Sub
If you wish to go to a new record, include this command:
DoCmd.GoToRecord, , acNewRec
Also, if you wish to have Category enabled only on a new record, remove that code from the Add button and replace it with this line in the OnCurrent event of the form:
Category_Desc.Enabled = Me.NewRecord

Opening new form after right click on selected record in continuous form

In my access database before I was using a list box in the form for having list of items and I had below code for opening new form after right click on each selected item in list box.
Private Sub ItemList_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
Const RIGHTBUTTON = 2
If Button = RIGHTBUTTON Then
DoCmd.OpenForm "frmShortcut_GenerateTask"
DoCmd.MoveSize udtPos.X * mp.TwipsPerPixelX, udtPos.Y * mp.TwipsPerPixelY
End If
End Sub
Now I am using a continuous form instead of list box and I have defined a [isselected) field for selecting each record in continuous form after clicking on that. Now my problem is how I have to write code for right clicking and opening new form.
I used the same code I had used for list box, but it does not work and nothing happened.
Private Sub Form_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
Const RIGHTBUTTON = 2
If Button = RIGHTBUTTON Then
DoCmd.OpenForm "frmShortcut_GenerateTask"
DoCmd.MoveSize udtPos.X * mp.TwipsPerPixelX, udtPos.Y * mp.TwipsPerPixelY
End If
End Sub
Private Sub P_Click()
On Error Resume Next
Me.IsSelected = Not Me.IsSelected
' Save the status
Me.Dirty = False
' Force conditional highlighting
P_ForceHighLight
' Update display in SF_Selected
Me.Parent("SF_Selected").Requery
ActiveControl.SelLength = 0
On Error GoTo 0
End Sub
I recommend either using a DoubleClick event in all of your textboxes and combos, or else putting a small button at one edge of your continuous form that allows the user to open records. Right-click is going to give you problems (so will labels and image controls) because this event doesn't cause (or ensure) that the Form's internal Recordset Bookmark property is actually moved to the record they right-clicked on. In my experience, only buttons, textboxes, and comboboxes will move the Bookmark to the record the user is trying to select.
To Test this, try putting code at the top of your different routines that shows you what record is selected:
MsgBox "RecordID = " & Me!RecordIDField
If you are consistently getting the correct ID, then your problem has to do with how your opening your new form, passing parameters or arguments, etc.

rad menu , check if item text exists

Using telerik and the radmenu, do you know how to check if the item exists by text
my menu contains the text "menu1"
If I use menu.FindItemByText("menu1").Enabled = False this will disable the button
BUT
If I use menu.FindItemByText("menuTEST").Enabled = False then I get an exception as this button does not exist.
How do I stop the error?
I tried this below but it say it cant return booloen
If menu.FindItemByText("menuTEST") then
'do this
End If
Try this:
If Not(menu.FindItemByText("menuTEST") Is Nothing) then
'do this
End If