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

Form with selection box

Status
Not open for further replies.

lpgagirl

Technical User
Feb 3, 2003
202
CA
I have a form with a selection box control. The user selects a location and the record is displayed on fields to the left of it. The fields are the same width and height stacked on top of each other looking like a grid. The problem I have is that when the user switches his selection in the control the record fields display all mubble jumbled. When I move the vert. scroll bar or the mouse wheel it fixes the problem and the data is displayed. I have attached the mousehook wheel module to the OnOpen event of the form and it fixed the data rolling away problem I had but still the a/n occurs. Help please.

Thanks in advance,


Jeannie
 
How are ya lpgagirl . . .

. . . and if you disable the mousewheel hook?

Calvin.gif
See Ya! . . . . . .
 
Hi TheAceMan1!,

When I make a selection it looks like the form moves up, as indicated by the scroll bar (it moves down). I will try flushing my cache by rebooting and let ya know.

Jeannie
 
lpgagirl . . .

Before I decide what to post back . . . [blue]just how did you disable the hook?[/blue]

Calvin.gif
See Ya! . . . . . .
 
Sorry for the delay.....

1. I have a mouse hook Module heres the code:[/color red]
Option Compare Database
Option Explicit


Private Declare Function LoadLibrary Lib "kernel32" _
Alias "LoadLibraryA" (ByVal lpLibFileName As String) As Long

Private Declare Function FreeLibrary Lib "kernel32" _
(ByVal hLibModule As Long) As Long

Private Declare Function StopMouseWheel Lib "MouseHook" _
(ByVal hWnd As Long, ByVal AccessThreadID As Long) As Boolean

Private Declare Function StartMouseWheel Lib "MouseHook" _
(ByVal hWnd As Long) As Boolean

Private Declare Function GetCurrentThreadId Lib "kernel32" () As Long

' Instance returned from LoadLibrary call
Private hLib As Long


Public Function MouseWheelON() As Boolean
MouseWheelON = StartMouseWheel(Application.hWndAccessApp)
If hLib <> 0 Then
hLib = FreeLibrary(hLib)
End If
End Function

Public Function MouseWheelOFF() As Boolean
Dim s As String
Dim blRet As Boolean
Dim AccessThreadID As Long

On Error Resume Next
' Our error string
s = "Sorry...cannot find the MouseHook.dll file" & vbCrLf
s = s & "Please copy the MouseHook.dll file to your Windows System folder or into the same folder as this Access MDB."

' OK Try to load the DLL assuming it is in the Window System folder
hLib = LoadLibrary("MouseHook.dll")
If hLib = 0 Then
' See if the DLL is in the same folder as this MDB
' CurrentDB works with both A97 and A2K or higher
hLib = LoadLibrary(CurrentDBDir() & "MouseHook.dll")
If hLib = 0 Then
MsgBox s, vbOKOnly, "MISSING MOUSEHOOK.dll FILE"
MouseWheelOFF = False
Exit Function
End If
End If

' Get the ID for this thread
AccessThreadID = GetCurrentThreadId()
' Call our MouseHook function in the MouseHook dll.
MouseWheelOFF = StopMouseWheel(Application.hWndAccessApp, AccessThreadID)

End Function


'******************** Code Begin ****************
'Code courtesy of
'Terry Kreft & Ken Getz
'
Function CurrentDBDir() As String
Dim strDBPath As String
Dim strDBFile As String
strDBPath = CurrentDb.Name
strDBFile = Dir(strDBPath)
CurrentDBDir = Left$(strDBPath, Len(strDBPath) - Len(strDBFile))
End Function
'******************** Code End ****************

2. I have an event procedure OnOpen of the form[/color red]here is the code for that:
Dim blRet As Boolean
blRet = MouseWheelOFF

3. Finally I have a mousehook.dll file [/color red]that resides in the same folder as the database that supports the code.

Jeannie
 
lpgagirl . . .

In the event your using for your selection box control, try using the [blue]Application.Echo[/blue] method.
Code:
[blue]   Application.Echo False
   [green]'
   Your Code
   '[/green]
   Application.Echo True[/blue]

Calvin.gif
See Ya! . . . . . .
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top