Copy string of values from form (1 Viewer)

garywood84

Registered User.
Local time
Today, 20:57
Joined
Apr 12, 2006
Messages
168
I have a form which displays contact details for customers. I want to add a button to the form which concatenates name and address fields, adding spaces and line breaks, and then copies the full name and address so that it can be pasted into other applications (e.g. into a letter).

To do this requires that I implement some code to perform the following actions, but I can't figure out how to do it. Can anyone help?

1. Check Title field. If it is not null, take it's value and add a space after it.
2. Check First Name field. If it is not null, take it's value add it to the output of step 1 and add a space after it.
3. Check Surname field. If it is not null, take it's value and add it to the output of step 2 and add a space and a line break after it.
4. Check the Company Name field. If it is not null, add it's value after the line break and add another line break.
5. Repeat this for every field until the end of the address is reached, then copy the result.

Thanks in advance if anyone can help.

Gary
 

Uncle Gizmo

Nifty Access Guy
Staff member
Local time
Today, 20:57
Joined
Jul 9, 2003
Messages
16,282

Attachments

  • CopyAddress.zip
    37.4 KB · Views: 563
Last edited:

sblmisty

New member
Local time
Today, 15:57
Joined
Jan 3, 2013
Messages
1
Uncle Giz: A personal note of thanks to add to my vote of Thanks. I am so thrilled to find the answer to how to copy from a form to the clipboard. Not being profcient at VBA, it took me a while to figure out the code, so I could rename things to fit my application, but once I got it figured, it worked immediately (well, almost, due to some operator errors in renaming which were easily fixed thanks to Access's messages). Your name figures prominently in a comment in my version of your code. I am so grateful for the generosity you and people like you show on the Access forums. Everything I've learned, I've learned from all of you. Many thanks! Susan (from Virginia USA)
 
Last edited:

Users who are viewing this thread

Top Bottom