Link to home
Start Free TrialLog in
Avatar of TicketMan
TicketMan

asked on

Which event triggers (if any) when you paste data in a MS-Access datasheet-subform?

Hi Experts,

Is there any event that triggers when you paste data (records from an Excel spreadsheet) into a MS-Access datasheet-subform? Currently the user has to click  a button (in MS-Access) to process the data after he it has been pasted into a subform. I would like to eliminate that button (as it can be forgotten) and have the code behind that button work from the moment data has been pasted into the subform.

As far as I know, a subform has only 2 event triggers: 'On-Enter' and 'On-Exit'. Neither one of them trigger when I paste data in the subform.

Any ideas?

Thanks.
Avatar of Paul_Harris_Fusion
Paul_Harris_Fusion
Flag of United Kingdom of Great Britain and Northern Ireland image

Assuming your sub form is actually a form and not a query embedded as a sub-form..

I think you would have to put the event handler code into the sub-form itself, not in the parent form that contains the sub-form.

If you open the sub-form in design mode (you have to close the parent form first),  then you should see a bigger range of events.

Avatar of TicketMan
TicketMan

ASKER

Thanks Paul.
Yes, the subform is actually a form on itself. I looked into its own range of events (good thinking!), and tried the "AfterUpdate" of the subform but that doesn't do it.

The event "DataChange" doesn't trigger either when I paste data into the subform....
neither does the event "DataSetChange" trigger...
Perhaps these events don't trigger because the subform is in datasheet view?
Most of the events will work on a per-record basis.
The problem with a paste is that it can copy several records and the events will fire for each of them.

Is this the problem you encountered with AfterUpdate?

If so, your problem is in knowing when a paste has completed i.e. all records in the paste buffer have been transferred.

I am not aware of a method for doing this - sorry - maybe someone else on this forum has an idea?
ASKER CERTIFIED SOLUTION
Avatar of Paul_Harris_Fusion
Paul_Harris_Fusion
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Just realised, the subform in question isn't really a subform (my mistake not spotting this). Although it was created once in this project,  the Source Object of the so called subform-datasheet within the main form is set directly to the underlying table instead (not via another subform), hence the lack of event triggers to use here...