Can't use SendMessage...WM_PASTE with a regular Text Box

N

Neil

Anyone have any idea why

SendMessage ctl.hwnd, WM_PASTE, 0, 0

isn't working from a regular Access text box (form is opened normally, not
in dialog more)? I realize I can just use docmd.RunCommand acCmdPaste. But I
have a reason for needing to do it this way. When I run the code I get the
message, "Object doesn't support this property or method" (error 438). Any
ideas why this is happening? Thanks!

Neil
Here is the code I'm using:

Private Declare Function SendMessage _
Lib "user32" _
Alias "SendMessageA" ( _
ByVal hwnd As Long, _
ByVal wMsg As Long, _
ByVal wParam As Long, _
lParam As Any) As Long

Private Const WM_PASTE = &H302

Function MyFunc(ctl as control)
SendMessage ctl.hwnd, WM_PASTE, 0, 0
End Function
 
R

Ron Weiner

Access Controls as *VERY* lightweight. In order for the control to *even*
have an Hwnd the control must have the focus. Try setting the focus to the
control and then calling your paste routine.

Ron W
 
N

Neil

Thanks, but, yeah, it had the focus. Per my other post in this thread, the
problem seems to be the ctl.hwnd statement, which seems to be invalid in
Access. Need to be able to get the control handle.

Thanks!
 
N

Neil

Re. my other message, found some code by Dev Ashish that does that. Working
now. Thanks.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top