DoMenuItem

Rob.Mills

Registered User.
Local time
Today, 18:51
Joined
Aug 29, 2002
Messages
871
I've tried to write code to use the DoMenuItem several times and haven't gotten it to work. What I'm trying to do is on my continuous form I want to be able to click in a certain field and for it to automatically copy the value in that field.

I've set up this code in the on click property of the textbox:

Private Sub txtZCCode_Click()

DoCmd.DoMenuItem acFormBar, acEditMenu, acCopy, , acMenuVer70

End Sub

Everytime I click in that field I'm getting an error message.

Suggestions?
 
Have you tried using

DoCmd.RunCommand acCmdCopy

instead?

Hope this helps

Ian
 
Tried that but I got the message

"The command or action 'Copy' isn't available now.
 
You need to create a command button to do what you want. I noticed that it still errrors if the field is null so you will have to test for Nulls. Here is what you need to set the focus to the text box and copy it...

If IsNull(TextBox) Or TextBox = "" Then
MsgBox "Null field"
Exit Sub
Else
Me.TextBox.SetFocus
DoCmd.RunCommand acCmdCopy
End If

HTH
 
Tried that code as well but still keep getting the same error message.
 

Users who are viewing this thread

Back
Top Bottom