Copy and Pate Using SelStart (1 Viewer)

Tim Bedborough

Registered User.
Local time
Today, 12:59
Joined
Nov 16, 2015
Messages
42
Hi all

Got myself a bit stuck and possibly not starting in the right place to begin with !

Using Access 16

I want to use code to automate a copy and paste process. Copy from 2 controls/fields/Text Boxes on 1 form (frmEmail [Details] and [Body]) and paste into a single control in subfrmActivityDateOrder [Details].

I have managed to copy and paste OK but unable to make a character space between the first and second paste (so it all runs into 1 long sentence).

Happy to show all code for complete Private Sub but this is the bit I have got to where SelStart is being used (possibly not in the right way).
Any pointers much appreciated to achieve [Details] SPACE [Body].

'Copy and paste the email subject line into job card activity details
'If there is no data in the subject line prompt user to put one in

Forms.frmEmail.SetFocus
DoCmd.GoToControl "Subject"

If IsNull(Me.Subject) = False Then
DoCmd.RunCommand acCmdCopy
Forms.frmjobs.SetFocus
DoCmd.GoToControl "Details"
DoCmd.RunCommand acCmdPaste
Else
Forms![frmjobs]![subfrmActivityDateOrder].Form![Details] = "Give this activity a title"
End If

'Copy and paste the email body into job card activity details
'There should be some reference to the subject line (from the code above) followed by the pasted body of the email

Forms.frmEmail.SetFocus
DoCmd.GoToControl "Body"
DoCmd.RunCommand acCmdCopy
Forms.frmjobs.SetFocus
DoCmd.GoToControl "Details"
SelStart = Len(Details) 'Select the starting point for the cursor at the end of the [Details] text
DoCmd.RunCommand acCmdPaste
 

Minty

AWF VIP
Local time
Today, 13:59
Joined
Jul 26, 2013
Messages
10,371
Don't use copy and paste - simply create a string from the text boxes with a space added and update the subform control with the result. - Air code untested;
Code:
Dim sStringtoPaste as String

sStringtoPaste = me.Subject & " " & me.body
Forms![frmjobs]![subfrmActivityDateOrder].Form![Details] = sStringtoPaste
 

Tim Bedborough

Registered User.
Local time
Today, 12:59
Joined
Nov 16, 2015
Messages
42
Minty - superstar. Was I seriously doing it the long way round or what! Couldn't see wood for trees. Worked fine and much tidier looking. Thanks, much appreciated.
 

Minty

AWF VIP
Local time
Today, 13:59
Joined
Jul 26, 2013
Messages
10,371
You are welcome !

I like simple :) it matches me.
 

Users who are viewing this thread

Top Bottom