Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Copying into clipboard in access97

Status
Not open for further replies.

Dreamwalker

Programmer
Apr 30, 2002
43
US
Heya everyone ...

I have access97 in front of me ... I am trying to copy simple data from a text box I have on my form called Text0

Im wondering how I can take this data and auto copy it into the clipboard via VBA coding .. tried searching the web but did not found what I was searching for...

I would appreciate any help

Thanks
Vince

Quotes of the day : The worse thing on this planet is when you realize that everything you've learned is in fact just learned not necessarly true :)
 
Try this:

OnClick Event Procedure:

DoCmd.RunCommand acCmdCopy

Upon clicking the control the data from the control is copied to memory.

This can also be installed in the OnGotFocus Event Procedure so that as your users tab into the control it copies the data to memory.

After this a Right click and select paste will paste the data wherever the cursor is placed.

Good luck. Bob Scriver
 
Hey everyone

I will explain again my little problem. I won't use any foul language. I dont think I ever did but anyways.

I have a simple form ... with a simple text box. The only things I want to use is this text box the text box data and the windows clipboard.

Im trying to find a way to copy the data of the text into the clipboard by any ways there is. I tried accmdCopy like someone told me its not what I want. Could someone please help me with this

Thanks a lot
Vince
 
Dude, I can feel your pain, this message has been going around since that little incident yesterday. Have you tried writing a macro. I wrote a macro to copy and paste information. The only problem is I copy and paste to a table. I don't know how to paste or output to the clipboard.

Now here's a different thought. I don't have a clue about 97, but generate a report, and then export the information as a text file to word.

Why the heck do you want to put this text information on the clipboard anyway, maybe if you explain that someone can assist you better.
 
Ok :)

I know it seems wacky and things. But the thing is that Im working for a company wich I have no choice to deal with that lame program that I dont know who coded it. I have no access to source code and there is no mask for the phone #. I created a little form with a text box that has the mask ... I always have to copy paste in the text and recopy to get the number with the mask. I was wondering and Im pretty sure there is a way to auto copy into the clipboard of windows so all I would have to do is write the number in the text field and when it gets to its maxlen of the mask it auto copies in the clipboard ... I know it sounds lazy but I have to be has fast has possible and since the programmer is too lame to put in a mask I have to deal with this problem ...

Thanks for any help I appreciate it

Vince
 
So basically in laymens terms

You want to be able to setup a mask (XXX)000-0000, 10 digits long.

When the last number is typed or 10th digit you would like for the entire number to be copied to the clipboard, something like a auto copy.

Can you click a button? Would you like that?

Put a button next to you text box.
This text box place the information into a table somewhere, right. Good. If not Stop here and wait for someone else to comment.
And now here is the juice........

Create Macro "MoveToClip"

OPEN table (This is the table where the masked record is kept)

RUNCOMMAND Selectall records (Now you can play with this one and you may be able to get it to select the one item you want)
RUNCOMMAND Copy

Now your information is on the clipboard and you can paste it where ever your heart desires.


 
Vince,
Have you tried to work with your textbox? Format it with your mask and reference the control source to the phone number field.
jim
 
Thanks a lot everyone for your help

Ok 1st... the macro thingy would work but Im not using any button or any tables from the database like I said earlier.
For you Jim ... the program that has the unmasked text field is not mine its another application Im using ... and I cant do anything about it ... I only want to use that text field and the clipboard ... I know the way to check if the number is entered ... but I have no idea how to take the data and auto copy it into the clipboard w/o using the database at all. Its only VBA and that text field. But if there is no way to do this I might figure a way with the DB but Im more than sure that your not obligated to use DB to copy into the clipboard

Thanks for the help I appreciate a lot

Vince
 
Ok, If you can check to see if the number is entered then you should be able to just add the line

docmd.RunCommand acCmdCopy

And you are right, it doesn't work. What I found is that in order for it to copy, I have to first open the table or query or whatever then with this command it copies the first record.

If you use:

docmd.RunCommand acCmdSelectAll

Then it will select everything......

Example:
Dim stDocName As String
stDocName = "Query - Review Comment List"

DoCmd.OpenQuery stDocName, acNormal, acEdit

DoCmd.RunCommand acCmdSelectAllRecords
DoCmd.RunCommand acCmdCopy

I know you stated that you are not usng any tables or anything, my question is how are you using Access without tables? I'm still pretty new at this and that has just thrown me for a loop because I thought Dbases were based on tables and queries?

Anyway, this will copy the info onto the clipboard and it is all VB

Good luck

[peace]


 
I just read back through the post, forget my previous message. It's the same as you tried before....
 
Here is how I wrote the code for what you are looking for. Exact code:

Private Sub TeleNumbers_Enter()
On Error GoTo Err_TeleNumbers_Enter

Dim stDocName As String

stDocName = "Table1"
DoCmd.OpenForm stDocName, acNormal, acEdit

DoCmd.RunCommand acCmdCopy


Exit_TeleNumbers_Enter:
Exit Sub

Err_TeleNumbers_Enter:
MsgBox Err.Description
Resume Exit_TeleNumbers_Enter
End Sub


After you type in all the numbers and hit ENTER it copies the number to the clipboard.

In order to do this you are going to have to set up a table. Now, from your previous email I know you do not want to do this, but if you want this to work you need the table.

Setup table in design view.
Call it "Table1".
First field Call it TeleNumber.
Data type Text.
In the GENERAL tab at bottom of page set the input mask (000) xxx-xxxx.
Save.

Build a form using the wizard.
Select the Table1 and click Next until done.

Now the form is set and you are ready.

Open form in design view.

Right click the textbox and choose properties.
Find where it says OnEnter, Select [Event Procedures].
Then click the button with 3 dotsThis will open the VB screen.
Enter the code at the top of the page and you can go home happy........


 
Heya there

Thanks a lot for that solution. I thought of that one but it uses tables. At least it does what I want :) Thanks again I will use that one .. guess there is no way to simply select and put in clipboard w/o using those tables.

The Dreamwalker
 
There are API calls for handling the clipboard. Look at for examples. This allows you to put any text on the clipboard, whether it is in a variable or in a control.

Best regards
 
Private Sub FolderName_AfterUpdate()
FolderName.SelStart = 0
FolderName.SelLength = Len(FolderName)
DoCmd.RunCommand acCmdCopy
End Sub

This will copy the contents of text box onto the clipboard.

acCmdCopy behaviour: if no text is selected, the entire record is copied onto the clipboard. If you select the necessary text, you solved your problem of copying the info.

Good luck
[pipe]
Daniel Vlas
Systems Consultant
danvlas@yahoo.com
 
Hey Thanks for the tip Danvlas I had a different variation of this but it didn't always work on every PC i was running. Yours is working on all ot them.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top