SpiritOfLennon
IS-IT--Management
Hi,
I have the following section of VB code which runs a query on an access database and displays the result in a dataview. It used to work fine on Access 97, now however the database has been upgraded to 2000 and when I try and run it, it seems to get stuck in the loop section. Any ideas what the difference is between 97 and 2000 that could be causing the problem?
Regards SOL
Sub OpenQuery(qryName As String)
Dim oAccess As Object, lHandle As Long, lAccessHwnd As Long
On Error GoTo QueryError
Screen.MousePointer = vbHourglass
Set oAccess = CreateObject("Access.Application.9")
oAccess.OpenCurrentDatabase DBname, False
oAccess.DoCmd.OpenQuery qryName
oAccess.DoCmd.Maximize 'maximize the display window
lAccessHwnd = oAccess.Application.hWndAccessApp
If IsIconic(lAccessHwnd) Then ShowWindow lAccessHwnd, SW_SHOWNORMAL
ShowWindow lAccessHwnd, SW_SHOWMAXIMIZED
lHandle = oAccess.Forms("frmMainMenu").hwnd
'Do While IsWindow(lHandle)
' DoEvents
'Loop
oAccess.Quit 2 'acQuitSaveNone
Set oAccess = Nothing
GoTo OpenQuery_Exit
QueryError:
MsgBox Error
OpenQuery_Exit:
Screen.MousePointer = vbDefault
End Sub
I have the following section of VB code which runs a query on an access database and displays the result in a dataview. It used to work fine on Access 97, now however the database has been upgraded to 2000 and when I try and run it, it seems to get stuck in the loop section. Any ideas what the difference is between 97 and 2000 that could be causing the problem?
Regards SOL
Sub OpenQuery(qryName As String)
Dim oAccess As Object, lHandle As Long, lAccessHwnd As Long
On Error GoTo QueryError
Screen.MousePointer = vbHourglass
Set oAccess = CreateObject("Access.Application.9")
oAccess.OpenCurrentDatabase DBname, False
oAccess.DoCmd.OpenQuery qryName
oAccess.DoCmd.Maximize 'maximize the display window
lAccessHwnd = oAccess.Application.hWndAccessApp
If IsIconic(lAccessHwnd) Then ShowWindow lAccessHwnd, SW_SHOWNORMAL
ShowWindow lAccessHwnd, SW_SHOWMAXIMIZED
lHandle = oAccess.Forms("frmMainMenu").hwnd
'Do While IsWindow(lHandle)
' DoEvents
'Loop
oAccess.Quit 2 'acQuitSaveNone
Set oAccess = Nothing
GoTo OpenQuery_Exit
QueryError:
MsgBox Error
OpenQuery_Exit:
Screen.MousePointer = vbDefault
End Sub