473,883 Members | 1,767 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Why is the filter not working?

83 New Member
Hi All,

First of all A Happy New Year to one and all.

I downloaded this small sample database from Allenbrowne’s site at the following page http://allenbrowne.com/AppFindAsUType. html .

I have modified it to suit my working database. I have added a new form to the sample. When a company name is searched and not found, it can be added using “Add New Customer”.

What I am trying to do is when I close the “Add New Customer” form, I am using the company name to be pasted in the “txtFindAsUType Value” text box, but it is not filtering and showing the record.

What am I doing wrong? Thanks to all in advance
Attached Files
File Type: zip FindAsUType2000.zip (70.4 KB, 132 views)
Jan 31 '13 #1
8 13281
5,501 Recognized Expert Moderator Expert
Are you sure that you had the form in question requery after adding the new record?

(sorry, I don't have time to download and disect your database)
Jan 31 '13 #2
12,516 Recognized Expert Moderator MVP
As a rule of thumb, and for security purposes, I do not download files from stranger. Please post all relevant info and code in the thread itself.
Jan 31 '13 #3
8,834 Recognized Expert Expert
You must:
  1. Explicitly Save the newly added Record in the AddCustomers Form.
  2. Define the Filter based on the newly added Company Name.
  3. These steps must be taken before the Form is closed and the Focus shifts back to the Filter Form.
  4. The General idea, in its simplest form, would be:
    Expand|Select|Wrap|Line Numbers
    1. Dim stOpenArgs As String
    3. stOpenArgs = Me.CompanyName.Value
    5. Me.Dirty = False    'Explicit Save Record
    7. With Forms!CustomersFinder
    8.   !txtFindAsUTypeValue.SetFocus
    9.   !txtFindAsUTypeValue.Value = stOpenArgs
    10.   .Filter = "[CompanyName] = '" & stOpenArgs & "'"
    11.   .FilterOn = True
    12.   !txtFindAsUTypeValue.Requery
    13. End With
    15. DoCmd.Close
Jan 31 '13 #4
32,584 Recognized Expert Moderator MVP
Please check out these links before posting any new questions :
How to ask "good" questions -- READ BEFORE SUBMITTING A QUESTION!.
Before Posting (VBA or SQL) Code.
Jan 31 '13 #5
83 New Member
Adezii, thanks for the answer. It is working very well with the sample database that I downloaded. when I tried to integrate it into my database, I was getting an error message "Data mismatch in criteria expression"!
Feb 1 '13 #6
8,834 Recognized Expert Expert
If the Field that you are filtering on is Numeric (let's assume a LONG INTEGER), then the Line of Code assigning the Filter would be:
Expand|Select|Wrap|Line Numbers
  1. .Filter = "[<FilterField>] = " & CLng(stOpenArgs)
P.S. - If this approach does not work, show the actual Code you are using.
Feb 1 '13 #7
5,501 Recognized Expert Moderator Expert
I was getting an error message "Data mismatch in criteria expression"!
Why didn't you provide that information to begin with?

Have you done as noted within the first section with the compile: Before Posting (VBA or SQL) Code as asked by Neopa?

You might want to tell us ANYTHING else you forgot to mention? Maybe you'd like to tell us all of the modifications you've made to the basic design and any other errors.
Feb 1 '13 #8
83 New Member

Thanks for your suggestion. Working well now.

I have another problem. Once the form "Add New Customer" is clicked and the user tries to close the form without adding a new customer, a warning "invalid use of null" pops up and the user can not close the form.

How do I get around this.
Feb 2 '13 #9

Sign in to post your reply or Sign up for a free account.

Similar topics

by: BlackFireNova | last post by:
I need to write a report in which one part shows a count of how many total records fall within the working days (Monday - Friday) inside of a (prompted) given date range, in a particular geographical region. I have written a query which prompts the user for the start and end dates. It also filters for entries which pertain to the particular geographical region. I'm not sure where to go from here.
by: Richard | last post by:
Hi, I have a form based on a table. When I filter the form I want to run a report based on the same table with the same filter as the form. No problem until I want to filter a combo box where the text value is on a different table. The me.filter is then a text instead of the id-number from the lookup table. This causes the report to prompt for the parameter. How do I get by this problem? Do I need to create a temporary table? I rather...
by: Nhmiller | last post by:
This is directly from Access' Help: "About designing a query When you open a query in Design view, or open a form, report, or datasheet and show the Advanced Filter/Sort window (Advanced Filter/Sort window: A window in which you can create a filter from scratch. You enter criteria expressions in the filter design grid to restrict the records in the open form or datasheet to a subset of records that meet the criteria.), you see the design...
by: Paul de Goede | last post by:
I set the Response.Filter in my aspnet application but I have noticed that if you do a Server.Transfer that the filter doesn't get called. And in actual fact the response is mostly empty. It seems that only scripts get rendered. I have seen this mentioned on this newsgroup before but with no resolution. Can anyone give any insight into this problem. Is there a work around? Manually push the Reponse.OutputStream through your filter after...
by: Anandan | last post by:
Hi, In our Project we use Dataset to load the Grid with Values. We have some criteria to filter the values to be shown in the Grid. For that we used the SELECT command to filter the Same Dataset. The SELECT Command we are using is as follows DS.Tables(0).Select("FieldName = '" & input value & "')
by: GazMathias | last post by:
Hi Guys, Acc2003. I have a form that is misbehaving by suddenly refusing to apply a filter I am passing to it. In a nutshell, I use a public variable to control the form's behaviour called gstrAction. I have a listbox on the preceding form containing record summaries that I use to open the new form with two buttons:
by: kcropper | last post by:
Hi, I’ve been trolling these forums for a while now, and while I’ve found other related threads (e.g., http://bytes.com/topic/access/answers/702416-search-code-how-filter-using-code-sql), nothing has addressed my problem, so I’m going to have to post. :) I’m using Access 2007. I have a form with a sub-form. I want to filter for text in the subform and only display records in the main form that have subforms matching the filter text. I have...
by: Adam Tippelt | last post by:
Situation: I'm using a continuous form to display a lot of information stored in a datasheet. I'm using the form because it allows me to display multiple rows of information per 'record' which is needed as some of the records have a lot of text. However, I've needed to apply both a form of filtering system, and a way of re-ordering the form so that it is alphabetical/numerical order, depending on whiching heading is clicked. I have achieved...
by: Pietro Malerba | last post by:
Hello! I'm testing quicksand script (http://razorjack.net/quicksand/) to filter some image. I had implemented the script with some image (http://www.hostingcubo.com/quicktest.php) 
As you can see there are circle, pentagon and triagle with different color. 
The filter are working fine tnx to this inline script: <script type="text/javascript" charset="utf-8"> (function($) { $.fn.sorted = function(customOptions) { var...
by: Ian Anderson | last post by:
Hello there, SO i have the followign VB code in my continuous form... 'Purpose: This module illustrates how to create a search form, _ where the user can enter as many or few criteria as they wish, _ and results are shown one per line. 'Note: Only records matching ALL of the criteria are returned. 'Author: Allen Browne (allen@allenbrowne.com), June 2006. Option Compare Database
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.