473,387 Members | 1,705 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

ApplyFilter in mde

Can anyone tell me why:
DoCmd.ApplyFilter, "ElectID = " & vNewElectID
should work in an mdb, but fail when the file is converted to an mde. It
fails with a 'Enter Parameter Value: ElectID" message.

After playing around with it, I inserted:
Me.Requery
immediately before the ApplyFilter and it now works in the mde.

So while the problem is solved, I cannot see why should it have been
different in the mdb and mde????

Has anyone else experience similar problems?
--
Bob Darlington
Brisbane
Nov 13 '05 #1
4 2282
Hi Bob

As I'm sure you realize, there is no good reason for this line of code to
work in an MDB but not in an MDE. It therefore has to be either a
corruption, or a side-effect of something else that's going on.

Name AutoCorrect would be the first culprit. Make sure the boxes are
unchecked under:
Tools | Options | General | Name AutoCorrect
For a list of *some* of the problem caused by this misfeature, see:
http://www.allenbrowne.com.au/bug-03.html

After that, compact the database:
Tools | Database Utilities | Compact

Now close Access, and decompile by entering something like this at the
command prompt while Access is not running. It is all one line, and include
the quotes:
"c:\Program Files\Microsoft office\office\msaccess.exe" /decompile
"c:\MyPath\MyDatabase.mdb"

Compact again. That should clear out the kinds of corruption that cause
trigger the behavior you describe.

If the record is dirty, Access has to save it before the filter can be
applied, and there are some rather odd side effects of the implicit save.
The code could also fail if the vNewElectID is null or a zero-length string,
so you might try coding like this:
If Me.Dirty Then
Me.Dirty = False
End If
Me.Filter = "ElectID = " & Nz(vNewElectID, 0)
Me.FilterOn = True

After that, you can try creating another MDE. Hopefully the problem is now
gone.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Bob Darlington" <bo*@dpcmanAX.com.au> wrote in message
news:42**********************@news.optusnet.com.au ...
Can anyone tell me why:
DoCmd.ApplyFilter, "ElectID = " & vNewElectID
should work in an mdb, but fail when the file is converted to an mde. It
fails with a 'Enter Parameter Value: ElectID" message.

After playing around with it, I inserted:
Me.Requery
immediately before the ApplyFilter and it now works in the mde.

So while the problem is solved, I cannot see why should it have been
different in the mdb and mde????

Has anyone else experience similar problems?
--
Bob Darlington
Brisbane

Nov 13 '05 #2
"Bob Darlington" <bo*@dpcmanAX.com.au> wrote:
Can anyone tell me why:
DoCmd.ApplyFilter, "ElectID = " & vNewElectID
should work in an mdb, but fail when the file is converted to an mde. It
fails with a 'Enter Parameter Value: ElectID" message.


Is the variable correctly declared with 'option explicit' also set?

Keith.
www.keithwilby.com
Nov 13 '05 #3
Thanks Allen,
Auto correct was turned off, but it wasn't always. So I guess the solution
may be contained in the last sentence of your reference. Will need to bite
the bullet and just do it.

--
Bob Darlington
Brisbane
"Allen Browne" <Al*********@SeeSig.Invalid> wrote in message
news:42***********************@per-qv1-newsreader-01.iinet.net.au...
Hi Bob

As I'm sure you realize, there is no good reason for this line of code to
work in an MDB but not in an MDE. It therefore has to be either a
corruption, or a side-effect of something else that's going on.

Name AutoCorrect would be the first culprit. Make sure the boxes are
unchecked under:
Tools | Options | General | Name AutoCorrect
For a list of *some* of the problem caused by this misfeature, see:
http://www.allenbrowne.com.au/bug-03.html

After that, compact the database:
Tools | Database Utilities | Compact

Now close Access, and decompile by entering something like this at the
command prompt while Access is not running. It is all one line, and
include the quotes:
"c:\Program Files\Microsoft office\office\msaccess.exe" /decompile
"c:\MyPath\MyDatabase.mdb"

Compact again. That should clear out the kinds of corruption that cause
trigger the behavior you describe.

If the record is dirty, Access has to save it before the filter can be
applied, and there are some rather odd side effects of the implicit save.
The code could also fail if the vNewElectID is null or a zero-length
string, so you might try coding like this:
If Me.Dirty Then
Me.Dirty = False
End If
Me.Filter = "ElectID = " & Nz(vNewElectID, 0)
Me.FilterOn = True

After that, you can try creating another MDE. Hopefully the problem is now
gone.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Bob Darlington" <bo*@dpcmanAX.com.au> wrote in message
news:42**********************@news.optusnet.com.au ...
Can anyone tell me why:
DoCmd.ApplyFilter, "ElectID = " & vNewElectID
should work in an mdb, but fail when the file is converted to an mde. It
fails with a 'Enter Parameter Value: ElectID" message.

After playing around with it, I inserted:
Me.Requery
immediately before the ApplyFilter and it now works in the mde.

So while the problem is solved, I cannot see why should it have been
different in the mdb and mde????

Has anyone else experience similar problems?
--
Bob Darlington
Brisbane


Nov 13 '05 #4
Thanks Keith,
The answer is 'yes' to both your suggestions, but was worth double checking.

--
Bob Darlington
Brisbane
"White Bilky" <ke*********@AwayWithYerCrap.com> wrote in message
news:Xn***********************@10.15.188.42...
"Bob Darlington" <bo*@dpcmanAX.com.au> wrote:
Can anyone tell me why:
DoCmd.ApplyFilter, "ElectID = " & vNewElectID
should work in an mdb, but fail when the file is converted to an mde. It
fails with a 'Enter Parameter Value: ElectID" message.


Is the variable correctly declared with 'option explicit' also set?

Keith.
www.keithwilby.com

Nov 13 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Michelle Dennard | last post by:
I am attempting to use the ApplyFilter command on a form in access and I am having some questions. Basically I have a form inwhich I select three things that constitute a key for each item. 1)...
2
by: webvigator2k | last post by:
I have a database that I've converted from 8 seperate tables into one cumulative table. instead of having 8 unique tables, there are 8 different tags now (machine1, machine2 etc) that ID every...
4
by: Colin Spalding | last post by:
How can I use the ApplyFilter method when both the control source to be filtered, and the filter are variables. I have tried the following syntax: DoCmd.ApplyFilter , "strSubject ='" & strGroup...
3
by: Robert_5032 | last post by:
I cant get my filter to work with variables Its working fine if I "hardcode" the issueType I want to filter on. Works fine: DoCmd.ApplyFilter , "issueType = 1" Works NOT: DoCmd.ApplyFilter ,...
2
by: John Smith | last post by:
The following code will not work for filtering records on a form: DoCmd.ApplyFilter , "Award =" & Not Null I use the following line to filter for a series of Yes/No boxes without trouble: ...
1
by: Jimmy Stewart | last post by:
I have a continuous form with a list of items from a table. One of the fields in the table is "print". this allows the user to select items from the list on the form for printing in a report. on...
1
by: zamir | last post by:
hi, can you applyfilter to a form based on what a user will enter in a login screen and have a specific record show up on that form. the code i already have is this: DoCmd.ApplyFilter ,...
7
by: zamir | last post by:
hi, same problem with applyfilter but i'm close. what i have done so far is a log in screen that takes a username and password and the user name is stored in a variable called StrUserName. If...
2
by: dkohel | last post by:
What is wrong with the following code? I am trying to filter a form based on the selection of a combobox named cblPRD Dim currentFilter currentFilter = " = '" & Me!cboPRD & "'" Filter =...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.