views:

920

answers:

1

I have a user that is dealing with an Access Database continuous forms page where they can perform a bunch of filtering and data entry.

Occasionally the user wants to be able to select a few rows from this form and paste them directly into an email. Outlook formats the data into a table pretty nicely on its own but the problem we're having is that dropdown controls from the header are included in the pasted data as you can see below:

Employee_Absences
drpEmployee drpOrgDescrip lstTimeCode txtToDate txtFromDate chkShowExcused DESCR AbsenceDate Hours Excused_Hours Time Code employee_lookup.ORG_DESCRIP ImportedDate
      6/2/2009 1/1/2009 0 Bob 1/4/2009 4 0 VAC Medical 5/7/2009 4:51:31 PM
      6/2/2009 1/1/2009 0 Bill 1/4/2009 6 0 VAC Medical  5/7/2009 4:51:31 PM
      6/2/2009 1/1/2009 0 Betty 1/4/2009 4 0 VAC Medical 5/7/2009 4:51:31 PM
      6/2/2009 1/1/2009 0 Beth 1/5/2009 2 0 VAC Gamers 5/7/2009 4:51:31 PM

The user doesn't want to bother with deleting and reordering columns every time they want to include a couple rows in an email and it would be fairly unfriendly to force them into a separate report or datasheet just to get two or three rows. I've tried messing with the order of the parameters in the query that is populating the form but this doesn't help at all.

Is there some sort of Copy-to-Clipboard event that I can hook into and do some magic to the data rows? Any other suggestions?

+1  A: 

This is surely a layout problem on the form. Selecting rows of a continuous form should not copy the data from controls in the form header.

Perhaps I've misunderstood the problem?

It certainly is possible to put data on the clipboard. See this page:

Copy variables/control contents to memory

But for pasting into an email, you'd need plain text and the email would need to be displayed in a fixed-width font. Unless you want to write HTML, there is no easy way to format a table that will paste into a non-plain-text email. If they are sending in HTML (which they oughtn't be), an HTML table will work. If they are using RTF (and they oughtn't be), I don't know what happens if you paste HTML.

Try to figure out why the form header control is getting copied. My bet is that the user is not defining the initial selection correctly, and you teach them to do that (or engineer the subform to prevent it), you won't have to program anything -- which is the whole beauty of Access.

On another note, I don't believe in allowing edits in continuous or datasheet forms because if you need dynamic combo boxes and the like for data validation, it can lead to all sorts of problems. Instead, I use continuous and datasheet forms as lists and have a detail subform bound to the PK of the continuous/datasheet form so that when you select a record in the continuous/datasheet form, the data will appear in the editable detail subform.

I have just had too many problems with editing continuous and datasheet forms and that's why I've done that. The only exception I make for that is in an invoice-type form, where there is no good way to do it otherwise.

David-W-Fenton
Thanks for the link and the detail subform suggestion--For now I may just create a little clipboard button the user can press to copy data to the clipboard as determined by a separate VBA function.You don't know of any way to intercept their 'Copy-to-clipboard' operation (Ctrl+C or right-click context menu) to trigger execution of the VBA code do you?
nvuono
You can use Key Preview on the form to intercept and test for that keystroke. Not sure if that's what you need or not.
David-W-Fenton