From: Pamela on
I have a command button on my Main Form that is supposed to, on the OnClick
Event, set focus to a control on a subform and copy its contents and then
close the entire form but I am getting an error that "The command or action
"Copy" isn't available now." Any ideas about how to work around this?? The
OnGotFocus event of the text box to be copied runs it's own code that
concatenates text from all over the form. This box does have a tab stop but
I have it coded so that focus doesn't go to it directly for the user - only
for the purpose of copying here. Here is my code attached to the command
button trying to run the copy procedure:
On Error GoTo Err_cmdExit_Click
Me!sfrmInspection.Form!sfrmLocation.Form!frmDamage.Form!sfrmEstimate.Form!Text6.SetFocus
DoCmd.RunCommand acCmdCopy
DoCmd.Close
Exit_cmdExit_Click:
Exit Sub
Err_cmdExit_Click:
MsgBox Err.Description
Resume Exit_cmdExit_Click
End Sub
Thanks so much for any help!
Pamela
From: Tom Wickerath AOS168b AT comcast DOT on
Hi Pamela,

If I am reading your code correctly (?), you are attempting to copy the
value from a text box named "Text6", that is in a subform four levels deep to
your main form, ie.:

Main Form
---> Inspections subform
----> Locations subform
----> Damage subform
----> Estimate subform : Text6

Have you tried something like this?

On Error GoTo Err_cmdExit_Click
Dim strText As String

strText =
Me!sfrmInspection.Form!sfrmLocation.Form!frmDamage.Form!sfrmEstimate.Form!Text6 '<---All on one line

You might need to use the Nz function as well (I'm not really sure without
taking the time to set up a test):

strText =
Nz(Me!sfrmInspection.Form!sfrmLocation.Form!frmDamage.Form!sfrmEstimate.Form!Text6, "") '<---All on one line

This all looks pretty messy. Good Luck!


Tom Wickerath
Microsoft Access MVP
http://www.accessmvp.com/TWickerath/
__________________________________________

"Pamela" wrote:

> I have a command button on my Main Form that is supposed to, on the OnClick
> Event, set focus to a control on a subform and copy its contents and then
> close the entire form but I am getting an error that "The command or action
> "Copy" isn't available now." Any ideas about how to work around this?? The
> OnGotFocus event of the text box to be copied runs it's own code that
> concatenates text from all over the form. This box does have a tab stop but
> I have it coded so that focus doesn't go to it directly for the user - only
> for the purpose of copying here. Here is my code attached to the command
> button trying to run the copy procedure:
> On Error GoTo Err_cmdExit_Click
> Me!sfrmInspection.Form!sfrmLocation.Form!frmDamage.Form!sfrmEstimate.Form!Text6.SetFocus
> DoCmd.RunCommand acCmdCopy
> DoCmd.Close
> Exit_cmdExit_Click:
> Exit Sub
> Err_cmdExit_Click:
> MsgBox Err.Description
> Resume Exit_cmdExit_Click
> End Sub
> Thanks so much for any help!
> Pamela