Link to home
Start Free TrialLog in
Avatar of Connie Jerdet-Skehan
Connie Jerdet-SkehanFlag for United States of America

asked on

insert code into module from a form

I am using Access in office 365 and sql server 2014

I have a unbound text box where I have written updating code based on field values. I also created a button to copy the code to a clip board which I then copy into a module. Is there a way to copy the code straight to module? Or copy the code to a sql stored procedure?? If it is possible. How?
Avatar of Kevin Cross
Kevin Cross
Flag of United States of America image

Try using "Microsoft Forms 2.0 Object Library" from within Tools > References.
You then can Dim and instantiate (Set ... = New) MSForms.DataObject.  Once you have an instance of DataObject, use its GetFromClipboard method.

Something like this:
Dim strSQL As String
Dim dataObj As MSForms.DataObject
Set dataObj = New MSForms.DataObject
' Get text copied to the clipboard
dataObj.GetFromClipboard
' Set your SQL string from the first value in DataObject
strSQL = dataObj.GetText(1)

Open in new window


Hope that helps!
Avatar of Connie Jerdet-Skehan

ASKER

Microsoft Forms 2.0 object Library is not in my list of references. I am using Access in office 365.
Oh sorry didn't catch that.  I never used VBA in Office 365.  Would not believe it even is an option with the online editor.  I use Office 365 but have downloaded Office 2016 as well for things I need automation.
Are you asking how to modify VBA Code in a running application? That's not a good thing to do regardless of the platform.

Perhaps I've misunderstood, however, so could you please explain further, and perhaps provide an example of what you're trying to do.
Edited Screen shot attached.

On left side of form is what we get.  On right side of form is what we correct it to.
Text box at bottom of page is the code I wish to insert into an existing sql stored procedure. I want it to add the code not delete what is in the stored procedure already. My question is ... Can this be done?

Currently, I am clicking the copy to clipboard button I created (in Access 365) and pasting it into the stored procedure (in Sql). I am trying to automate this step.

I hope this is clearer in what I am trying to accomplish.
FORM1.png
This question needs an answer!
Become an EE member today
7 DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform.
View membership options
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.