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

VBA Code runs in Full Access 03 but crashes 03 Runtime

Status
Not open for further replies.

stateofjustin

IS-IT--Management
Sep 21, 2010
2
Process:

Open program (it is usually an .mde)
Program opens maximized
Click on minimize button in program:
______________________________________
Private Sub cmdMin1_Click()
fSetAccessWindow (SW_SHOWMINIMIZED)
End Sub
______________________________________

Program minimizes and crashes when run with the 2003 run-time, program runs fine in full 2003.

Using this VBA (WindowCtrl) code here:
_____________________________________________________
Option Compare Database

'************ Code Start **********
' This code was originally written by Dev Ashish.
' It is not to be altered or distributed,
' except as part of an application.
' You are free to use it in any application,
' provided the copyright notice is left unchanged.
'
' Code Courtesy of
' Dev Ashish
'
Global Const SW_HIDE = 0
Global Const SW_SHOWNORMAL = 1
Global Const SW_SHOWMINIMIZED = 2
Global Const SW_SHOWMAXIMIZED = 3


Private Declare Function apiShowWindow Lib "user32" _
Alias "ShowWindow" (ByVal hwnd As Long, _
ByVal nCmdShow As Long) As Long

Function fSetAccessWindow(nCmdShow As Long)
'Usage Examples
'Maximize window:
' ?fSetAccessWindow(SW_SHOWMAXIMIZED)
'Minimize window:
' ?fSetAccessWindow(SW_SHOWMINIMIZED)
'Hide window:
' ?fSetAccessWindow(SW_HIDE)
'Normal window:
' ?fSetAccessWindow(SW_SHOWNORMAL)
'
Dim loX As Long
Dim loForm As Form
On Error Resume Next
Set loForm = Screen.ActiveForm
If err <> 0 Then 'no Activeform
If nCmdShow = SW_HIDE Then
MsgBox "Cannot hide Access unless " _
& "a form is on screen"
Else
loX = apiShowWindow(hWndAccessApp, nCmdShow)
err.Clear
End If
Else
If nCmdShow = SW_SHOWMINIMIZED And loForm.Modal = True Then
MsgBox "Cannot minimize Access with " _
& (loForm.Caption + " ") _
& "form on screen"
ElseIf nCmdShow = SW_HIDE And loForm.PopUp <> True Then
MsgBox "Cannot hide Access with " _
& (loForm.Caption + " ") _
& "form on screen"
Else
loX = apiShowWindow(hWndAccessApp, nCmdShow)
End If
End If
fSetAccessWindow = (loX <> 0)
End

End Function

'************ Code End **********
_____________________________________________________


I need this program to run on the RT, and for the function to perform properly.

Any suggestions? =)
 
I added this for troubleshooting purposes:

On Error GoTo PROC_ERR

PROC_ERR:
MsgBox "Error: (" & Err.Number & ") " & Err.Description, vbCritical

This returns a (0) which is supposed to mean no error.

Crashes anyway.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top