2475 - You entered an expression that requires a form to be the active window (1 Viewer)

chad101

Registered User.
Local time
Yesterday, 23:22
Joined
Dec 31, 2005
Messages
56
I have searched every nook and cranny and found no solutions for this problem…

My database hides the access window so it resembles a standalone application. I’m not sure if someone screwed with something, but today I noticed an error while opening the database.

Error #: 2475

You entered an expression that requires a form to be the active window.

I have used this database for years now and today is the first time I have encountered this error. I also have other databases which use this function to hide the access window. None of them encounter this problem when opened.

When I click debug, I’m directed to this function. And the below line is highlighted to yellow.

Function fSetAccessWindow(nCmdShow As Long)

Dim loX As Long
Dim loForm As Form
On Error Resume Next
Set loForm = Screen.ActiveForm

If Err <> 0 Then
loX = apiShowWindow(hWndAccessApp, nCmdShow)
Err.Clear
End If

EDIT:
I opened this database on two different PCs. Both are loading the main form with no errors. So the problem is isolated to this machine. Now if I can find out why…

EDIT # 2:
I cannot find the culprit. As I mentioned already, the database is loading fine on every machine except for the main workstation. Which I have used for years now...

I also receive this error when I open any database that hides the access window. So something was changed in the settings…

This is strange as hell and I’m lost for ideas. This is what I have tried so far

Updated to Office 2003 w/ SP 3 – no help
Reinstalled MS Access – No Help
Set a 5 second timer to hide the access window once the form is loaded – no help
Checked my references (tools -> references) Nothing is labeled as “missing”

Access still complains about my main form not being an “active window”. I also noticed my custom error messages have vanished. When I encounter an error I get the “debug” dialog box. No custom message boxes.

Again, this problem is only with the main workstation. All my other machines load the database just fine with no errors.
 
Last edited:

chad101

Registered User.
Local time
Yesterday, 23:22
Joined
Dec 31, 2005
Messages
56
I fixed the hide access window error.
Code:
Private Sub Form_Load()
Me.Visible = True
DoEvents
Call fSetAccessWindow(SW_HIDE)
End Sub



But my error handling is still not working correctly. For example if a user clicks the navigation button past the last record; they should receive a prompt telling them that they "can't go to the specified record". Instead they receive the runtime-error dialog box, which should never happen.



Basically the "On Error GoTo" command is not working...
When an error occurs within a function or sub my error handling code is never executed
 

boblarson

Smeghead
Local time
Yesterday, 20:22
Joined
Jan 12, 2001
Messages
32,059
You might have the Break on ALL errors selected instead of Break on Unhandled Errors. Go to the code window and to TOOLS > OPTIONS and check that out.
 

chad101

Registered User.
Local time
Yesterday, 23:22
Joined
Dec 31, 2005
Messages
56
Bob, I cannot tell you how happy I am! Thank you!:D

That was the problem. It’s fixed now
 

xolo

Registered User.
Local time
Today, 10:22
Joined
May 6, 2009
Messages
34
I had the same problem and I fixed it with "me.Visible = True". Thanks! :D

But how do we solve it with the control? I keep getting this:

"Run-time Error '2474': The expression you entered requires the control to be in the active window."

My Sub is like this:
Private Sub Form_Load()
Dim FrmAct As Form
Dim CtlAct As control
Me.visible = True
Set FrmAct = Screen.ActiveForm
Set CtlAct = Screen.ActiveControl
Gbl_FrmAct = FrmAct.Name
Gbl_CtlAct = CtlAct.Name
End Sub
 

Users who are viewing this thread

Top Bottom