PDA

Click to See Complete Forum and Search --> : Getting Handles the hard way


JoshT
Nov 20th, 2000, 07:09 AM
Via VBA in Access 2000, how would I get the handles to the following:

On the Access Form, I've placed a MS Calendar Control 9.0 ActiveX Control. On that control are two combo boxes - one to pick the month and one to pick the year. Because this control has change events for the month and the year, but no built in method to find the values of the combo boxes, I'm assuming if I can get the handle to the controls somehow, I can then get the contents.

Anyone know how to do this? I got code from MS KB that works fine in VB6 but not VBA, so I'm pretty sure it can be done, unless there's some weird way Access keeps track of handles. There's an API call to get the handle of the window in focus, but I'm unsure if it would return the combo box's handle or the calendar's handle.

Thanks,
Josh

Here's the KB article with MS's code:
http://support.microsoft.com/support/kb/articles/Q193/9/67.ASP

Here's the API function and code someone on a VB usenet group provided me with.

Private Declare Function apiGetFocus _
Lib "user32" _
Alias "GetFocus" () As Long

Function FindControlHandle(ctl As Control) As Long

On Error Resume Next
ctl.SetFocus

If Err Then
FindControlHandle = 0
Else
FindControlHandle = apiGetFocus
End If

On Error GoTo 0
End Function