DavidWSchmucker
asked on
MS Access 2007 acCmdCopy not working
Hi,
Hope you can help. Have Access 2007, just upgraded to Win 7. This code was working under XP Pro now gives" Can't copy right now" - Error 2046. Here is the code. How do I handle this?
Thanks
Dim vRenFile As String
Dim vWho
vWho = Nz(Forms![Contact Details]![FROM WHO].Column(1))
vRenFile = Format$(Date, "yymmdd")
'Debug.Print vRenFile
vRenFile = vRenFile + " " + Nz(Forms![Contact Details]![Last Name]) + " " + Nz(Forms![Contact Details]![First Name]) + " Dog-" + Nz(Forms![Contact Details]![Dog Name]) + " FR-" + vWho + ".jpg"
Forms![Contact Details].WorkSpace = "C:\Documents and Settings\David Schmucker\My Documents\My Dropbox\1-1 SDT Photo Master\" & vRenFile
Forms![Contact Details]!WorkSpace.SetFocu s
DoCmd.RunCommand acCmdCopy
Forms![Contact Details].WorkSpace = ""
Hope you can help. Have Access 2007, just upgraded to Win 7. This code was working under XP Pro now gives" Can't copy right now" - Error 2046. Here is the code. How do I handle this?
Thanks
Dim vRenFile As String
Dim vWho
vWho = Nz(Forms![Contact Details]![FROM WHO].Column(1))
vRenFile = Format$(Date, "yymmdd")
'Debug.Print vRenFile
vRenFile = vRenFile + " " + Nz(Forms![Contact Details]![Last Name]) + " " + Nz(Forms![Contact Details]![First Name]) + " Dog-" + Nz(Forms![Contact Details]![Dog Name]) + " FR-" + vWho + ".jpg"
Forms![Contact Details].WorkSpace = "C:\Documents and Settings\David Schmucker\My Documents\My Dropbox\1-1 SDT Photo Master\" & vRenFile
Forms![Contact Details]!WorkSpace.SetFocu
DoCmd.RunCommand acCmdCopy
Forms![Contact Details].WorkSpace = ""
First, you coding is a bit "Loose"
A lot of things you "Got away" with in previous version of Access/Windows simply have been "tightende up and no longer work.
1.
Dim vRenFile As String
Dim vWho '? As What?
Please always explicitly set a dataype, else it will be a Variant
2.
<vRenFile = vRenFile + " " + Nz(Forms![Contact Details]![Last Name]) ...>
When concatenating in VBA, try to use the "&" instead of "+"
vRenFile = vRenFile & " " & Nz(Forms![Contact Details]![Last Name]) ...
3.
"WorkSpace" is a VBA keyword, please avoid using it for an object names
4.
All in all you, ... may just need to save the current form record...
...
Forms![Contact Details]!WorkSpace.SetFocu s
Docmd.RunCommand acSaveRecord 'Try adding this line
DoCmd.RunCommand acCmdCopy
...
JeffCoachman
A lot of things you "Got away" with in previous version of Access/Windows simply have been "tightende up and no longer work.
1.
Dim vRenFile As String
Dim vWho '? As What?
Please always explicitly set a dataype, else it will be a Variant
2.
<vRenFile = vRenFile + " " + Nz(Forms![Contact Details]![Last Name]) ...>
When concatenating in VBA, try to use the "&" instead of "+"
vRenFile = vRenFile & " " & Nz(Forms![Contact Details]![Last Name]) ...
3.
"WorkSpace" is a VBA keyword, please avoid using it for an object names
4.
All in all you, ... may just need to save the current form record...
...
Forms![Contact Details]!WorkSpace.SetFocu
Docmd.RunCommand acSaveRecord 'Try adding this line
DoCmd.RunCommand acCmdCopy
...
JeffCoachman
ASKER
Jeff, Thanks for the response.
I've selected simpler to get a grasp on it. I think I followed your instructions. This code still doesn't work. Any ideas?
Private Sub Command314_Click()
Dim vEm1 As String
vEm1 = Nz(Forms![contact details]![E-mail Address])
Forms![contact details].WorkSpace = vEm1
Forms![contact details]!WorkSpace.SetFocu s
DoCmd.RunCommand acCmdSaveRecord
DoCmd.RunCommand acCmdCopy
End Sub
I've selected simpler to get a grasp on it. I think I followed your instructions. This code still doesn't work. Any ideas?
Private Sub Command314_Click()
Dim vEm1 As String
vEm1 = Nz(Forms![contact details]![E-mail Address])
Forms![contact details].WorkSpace = vEm1
Forms![contact details]!WorkSpace.SetFocu
DoCmd.RunCommand acCmdSaveRecord
DoCmd.RunCommand acCmdCopy
End Sub
1. Please rename your "WorkSpace" object as not to be confused with the WorkSpace object in VBA...
2. Can that control/filed accept nulls?
3. Where are you running this cod from?
I see you are fully qualifying the form.
This is not needed if you are running this from the same form, ...you can use: Me.SomeControl
4. The Setfocus line is not really needed, try commenting it out.
2. Can that control/filed accept nulls?
3. Where are you running this cod from?
I see you are fully qualifying the form.
This is not needed if you are running this from the same form, ...you can use: Me.SomeControl
4. The Setfocus line is not really needed, try commenting it out.
ASKER
Here is the latest iteration. No joy.
Dim vEm1 As String
vEm1 = Me.[E-mail Address]
Me.[DumbTxt] = vEm1
DoCmd.RunCommand acCmdSaveRecord
DoCmd.RunCommand acCmdCopy
Was wondering if SENDKEYS could be used to do a CTRL C on the DumbTxt fld?
Any help is appreciated. Thanks.
Dim vEm1 As String
vEm1 = Me.[E-mail Address]
Me.[DumbTxt] = vEm1
DoCmd.RunCommand acCmdSaveRecord
DoCmd.RunCommand acCmdCopy
Was wondering if SENDKEYS could be used to do a CTRL C on the DumbTxt fld?
Any help is appreciated. Thanks.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
So you were using Win 7 *64 Bit*?
ASKER
No Win 7 - 32 bit. I saw something that said the copy command only works if the entry behavior is select entire field. Don't know if that is true or not.
ASKER
It worked
Hotkeys could be used, but there are issues with that as well (in fact, 2010 has some serious Hot Key issues when used with Tab controls).