Go Back   Access World Forums > Microsoft Access Discussion > Forms

 
Reply
 
Thread Tools Rating: Thread Rating: 2 votes, 5.00 average. Display Modes
Old 01-25-2008, 09:44 PM   #1
chad101
Registered User
 
Join Date: Dec 2005
Posts: 56
Thanks: 0
Thanked 0 Times in 0 Posts
chad101 is on a distinguished road
Exclamation 2475 - You entered an expression that requires a form to be the active window

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 by chad101; 01-26-2008 at 03:29 AM.
chad101 is offline   Reply With Quote
Old 01-26-2008, 08:53 PM   #2
chad101
Registered User
 
Join Date: Dec 2005
Posts: 56
Thanks: 0
Thanked 0 Times in 0 Posts
chad101 is on a distinguished road
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
chad101 is offline   Reply With Quote
Old 01-26-2008, 11:00 PM   #3
boblarson
Smeghead
 
boblarson's Avatar
 
Join Date: Jan 2001
Location: Oregon, USA
Posts: 32,068
Thanks: 97
Thanked 1,810 Times in 1,573 Posts
boblarson is a splendid one to behold boblarson is a splendid one to behold boblarson is a splendid one to behold boblarson is a splendid one to behold boblarson is a splendid one to behold boblarson is a splendid one to behold boblarson is a splendid one to behold
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.

__________________

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
boblarson is offline   Reply With Quote
Old 01-26-2008, 11:12 PM   #4
chad101
Registered User
 
Join Date: Dec 2005
Posts: 56
Thanks: 0
Thanked 0 Times in 0 Posts
chad101 is on a distinguished road
Bob, I cannot tell you how happy I am! Thank you!

That was the problem. It’s fixed now
chad101 is offline   Reply With Quote
Old 01-26-2008, 11:15 PM   #5
boblarson
Smeghead
 
boblarson's Avatar
 
Join Date: Jan 2001
Location: Oregon, USA
Posts: 32,068
Thanks: 97
Thanked 1,810 Times in 1,573 Posts
boblarson is a splendid one to behold boblarson is a splendid one to behold boblarson is a splendid one to behold boblarson is a splendid one to behold boblarson is a splendid one to behold boblarson is a splendid one to behold boblarson is a splendid one to behold
Quote:
Originally Posted by chad101 View Post
Bob, I cannot tell you how happy I am! Thank you!

That was the problem. It’s fixed now
Glad we could assist
__________________

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
boblarson is offline   Reply With Quote
Old 12-22-2009, 09:22 PM   #6
xolo
Registered User
 
Join Date: May 2009
Posts: 34
Thanks: 0
Thanked 0 Times in 0 Posts
xolo is on a distinguished road
Re: 2475 - You entered an expression that requires a form to be the active window

I had the same problem and I fixed it with "me.Visible = True". Thanks!

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

xolo is offline   Reply With Quote
Reply

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Access 2003 queries on Vista Steve Lang Windows 19 12-02-2009 09:23 AM
Preventing opening a form unless data is entered? and some other Q's. Compressor Forms 8 10-30-2006 04:20 AM
Triggering a macro to occur when a form window is closed Turbojohn Forms 2 08-17-2006 05:11 AM
[SOLVED] DoCmd.OpenForm Fails if Access is not the active window farbrook Forms 2 06-15-2006 02:49 AM
Database window shows after printing form sehmke Forms 1 02-17-2005 12:53 AM




All times are GMT -8. The time now is 07:10 AM.


Microsoft Access Help
General
Tables
Queries
Forms
Reports
Macros
Modules & VBA
Theory & Practice
Access FAQs
Code Repository
Sample Databases
Video Tutorials

Sponsored Links

How to advertise

Media Kit


Powered by vBulletin®
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.
(c) copyright 2017 Access World