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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Compile Error

Status
Not open for further replies.

rupertandolly

Programmer
Aug 5, 2005
8
AU
Hi,

(winxp - Access 2002 VBA)

I have the follwoing problem:

I have declared the following function:
Private Declare Function SendMessage Lib "User32" Alias "SendMessageA" (ByVal hWnd As Long, ByVal wMsg As Integer, ByVal wParam As String, lParam As Any) As Long
Const LB_FINDSTRING = &H18F

When the code below fires I get the following error:
Compile Error:
Method or Data member not found.

The VB editor opens and shows .hWnd highlighted below.
Am I missing a reference or something??

Private Sub Text41_Change()
JobHeader.ListIndex = SendMessage(JobHeader.hWnd, LB_FINDSTRING, _
Text41, ByVal Text41.Text)
End Sub
 
Only a Form or a Report have a hWnd property.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
That explains why hWnd does not appear in the listbox's property list. However there is a stack of code out there referencing a listbox's .hWnd property.

i.e. Dim ItemIndexes() As Long, x As Integer, iNumItems As Integer
iNumItems = ThisBox.SelCount
If iNumItems Then
ReDim ItemIndexes(iNumItems - 1)
SendMessage ListBox1.hwnd, LB_GETSELITEMS, iNumItems, _
ItemIndexes(0)
End If
For x = 0 To iNumItems - 1
MsgBox ListBox1.List(ItemIndexes(x))
Next x

How can it be??
 
Probably VB 6 standalone has this, whereas Access doesn't. I suppose if you really want to get fancy, you could use some API calls to enum the child windows of your form until you got the desired control and its hwnd.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top