Question

I work for a custom cabinetry manufacturer and we write our own pricing program for our product. I have a form that has a pop-up box so the user can select which side the hinge will be on for ambiguous doors on that cabinet. I've got that to work so far, but when they copy an item and paste it at the bottom I don't want the pop-up box to come up. Is there any way in Access VBA to know whether the new record is being pasted or entered manually?

Was it helpful?

Solution

You can customize the menu, for example if you add code like so to a standard module:

Public gvarPasted As Boolean

Function AssignVar()
    gvarPasted = True
    DoCmd.RunCommand acCmdPaste
End Function

You can set the Action property of Paste on the menu to this function using the customize option of the toolbar menu. You will also need to create your own shortcut menu (right-click menu) to use in place of the built-in menu. The shortcut menu can either be assigned for all forms or for just the form that requires it. It is also possible to turn off the shortcut menus for all forms.

OTHER TIPS

Perhaps something on the lines of this would suit.

Option Compare Database
Public gvarPasted As Boolean

Private Sub txtText_AfterUpdate()
If Not gvarPasted Then
    'Open pop-up here
Else
    gvarPasted = False
End If
End Sub

Private Sub txtText_KeyDown(KeyCode As Integer, Shift As Integer)
'Detect ctrl-V combination
If Shift = acCtrlMask And KeyCode = vbKeyV Then
    gvarPasted = True
End If
End Sub
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top