dbTalk Databases Forums  

ApplyFilter in OnOpen event

comp.databases.ms-access comp.databases.ms-access


Discuss ApplyFilter in OnOpen event in the comp.databases.ms-access forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Bob Darlington
 
Posts: n/a

Default ApplyFilter in OnOpen event - 02-13-2011 , 05:41 PM






I'm using an Access 2002 application in Access 2010 (as part of testing
before upgrading).
The behaviour described below doesn't happen when the same app is opened in
Access 2002.

I have a form called fMain from which I open another form using:
DoCmd.OpenForm "fElectSwitch", , , "PropNum = " & gblPropNum

The OnOpen event of fElectSwitch includes the line:
DoCmd.ApplyFilter, "ElectID = " & vElectID

When the form opens, I get an 'Enter Parameter Value ..ElectID" message.
I click OK (entering no value), and the form opens. When I then close the
form, fMain is a grey screen.
It appears that the filter has been applied to the form from which the
OpenForm call was made.

If I insert a new line in fElectSwitch OnOpen to set the focus to a control
on the form, there is no problem.

Whilst I can work around the problem, it appears to indicate that something
is wrong.
Anyone else experienced the problem?


Bob Darlington
Brisbane

Reply With Quote
  #2  
Old   
Phil
 
Posts: n/a

Default Re: ApplyFilter in OnOpen event - 02-14-2011 , 02:31 AM






On 13/02/2011 23:41:42, "Bob Darlington" wrote:
Quote:
I'm using an Access 2002 application in Access 2010 (as part of testing
before upgrading).
The behaviour described below doesn't happen when the same app is opened
in Access 2002.

I have a form called fMain from which I open another form using:
DoCmd.OpenForm "fElectSwitch", , , "PropNum = " & gblPropNum

The OnOpen event of fElectSwitch includes the line:
DoCmd.ApplyFilter, "ElectID = " & vElectID

When the form opens, I get an 'Enter Parameter Value ..ElectID" message.
I click OK (entering no value), and the form opens. When I then close the
form, fMain is a grey screen.
It appears that the filter has been applied to the form from which the
OpenForm call was made.

If I insert a new line in fElectSwitch OnOpen to set the focus to a
control on the form, there is no problem.

Whilst I can work around the problem, it appears to indicate that
something is wrong.
Anyone else experienced the problem?


Bob Darlington
Brisbane


Doesn't surprise me. You have 2 forms open, which one is the
DoCmd.ApplyFilter command going to apply to? My guess would be the form that
has the focus i.e. fMain.

Phil

Reply With Quote
  #3  
Old   
Bob Darlington
 
Posts: n/a

Default Re: ApplyFilter in OnOpen event - 02-14-2011 , 04:39 PM



"Phil" <phil (AT) stantonfamily (DOT) co.uk> wrote

Quote:
On 13/02/2011 23:41:42, "Bob Darlington" wrote:
I'm using an Access 2002 application in Access 2010 (as part of testing
before upgrading).
The behaviour described below doesn't happen when the same app is opened
in Access 2002.

I have a form called fMain from which I open another form using:
DoCmd.OpenForm "fElectSwitch", , , "PropNum = " & gblPropNum

The OnOpen event of fElectSwitch includes the line:
DoCmd.ApplyFilter, "ElectID = " & vElectID

When the form opens, I get an 'Enter Parameter Value ..ElectID" message.
I click OK (entering no value), and the form opens. When I then close the
form, fMain is a grey screen.
It appears that the filter has been applied to the form from which the
OpenForm call was made.

If I insert a new line in fElectSwitch OnOpen to set the focus to a
control on the form, there is no problem.

Whilst I can work around the problem, it appears to indicate that
something is wrong.
Anyone else experienced the problem?


Bob Darlington
Brisbane



Doesn't surprise me. You have 2 forms open, which one is the
DoCmd.ApplyFilter command going to apply to? My guess would be the form
that
has the focus i.e. fMain.

Phil
Thanks for the reply Phil.
The filter is applied in the OnOpen event of the form being opened, so that
is the form which should be filtered.
That is what happens in Access 2002 and what is indicated in MS Help for
Access 2010.
It looks as though I'm going to need to go through every form and check that
a .SetFocus is entered before a filter is applied.
--
Bob Darlington
Brisbane

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.