473,387 Members | 1,493 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.

Apply filter on number field

Can anybody out there help me please on apply filter in MS Access. I have a form that create from the query, which contain field chidid (text field), in the form footer, I add the button to open another form (searchF form), which have an unbound text box (text1). It works fine with this code:

DoCmd.ApplyFilter , "childid='" & Form_SearchF.Text1 & "'"

But if I change the data type of childid field to number it does't work. The error message is :

" Run-time error 2501
The Applyfilter action was canceled"

Your responds are highly appreciated.

Thanks.
Aug 22 '07 #1
2 11207
puppydogbuddy
1,923 Expert 1GB
Can anybody out there help me please on apply filter in MS Access. I have a form that create from the query, which contain field chidid (text field), in the form footer, I add the button to open another form (searchF form), which have an unbound text box (text1). It works fine with this code:

DoCmd.ApplyFilter , "childid='" & Form_SearchF.Text1 & "'"

But if I change the data type of childid field to number it does't work. The error message is :

" Run-time error 2501
The Applyfilter action was canceled"

Your responds are highly appreciated.

Thanks.
The syntax you are using above is for text data types. For a numeric data type the syntax would be as follows (remove the extra spaces inserted by the text editor):

DoCmd.ApplyFilter "childid=" & Form_SearchF.Text1

If you need to deal with both data types, you could do it like this:
Expand|Select|Wrap|Line Numbers
  1. If IsNumeric(Me!childid) then
  2.     DoCmd.ApplyFilter  "childid="  & Form_SearchF.Text1
  3. Else
  4.     DoCmd.ApplyFilter "childid='" & Form_SearchF.Text1 & "'"
  5. End If
Aug 22 '07 #2
The syntax you are using above is for text data types. For a numeric data type the syntax would be as follows (remove the extra spaces inserted by the text editor):

DoCmd.ApplyFilter "childid=" & Form_SearchF.Text1

If you need to deal with both data types, you could do it like this:
Expand|Select|Wrap|Line Numbers
  1. If IsNumeric(Me!childid) then
  2.     DoCmd.ApplyFilter  "childid="  & Form_SearchF.Text1
  3. Else
  4.     DoCmd.ApplyFilter "childid='" & Form_SearchF.Text1 & "'"
  5. End If


Thank you very much puppydogbuddy. It works well right now.
I appreciated your quick respond.
Aug 22 '07 #3

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

Similar topics

2
by: Mark | last post by:
Hi all, A form based on a query (qry_source_trailers) contains the field . In the forms header, I have placed an unbound text box where the afterupdate property is set to: DoCmd.ApplyFilter ,...
1
by: mattscho | last post by:
Re: Filter By From, Apply Filter, Remove Filter Buttons in a Form. -------------------------------------------------------------------------------- Hi All, Trying to create a set of 3 buttons in...
4
by: Fran | last post by:
I recently tried to use code for "Use a multi-select list box to filter a report" from Allen Browne in my database. I was able to add the code and adapt it to my needs, however I am getting an...
1
by: Barb.Richards | last post by:
I have created an append query that pulls information from one database, and will append the selected information into a new table. The fields are setup like 'number' 'category' 'code' 'shares' and...
8
by: Abedin | last post by:
I have 9 digits in form of "111020402". Then I have another 9 digits in form of "111020403". I have 100,000 records of these two 9-digit numbers. I want to filter this as follows: District:...
1
by: Supermansteel | last post by:
I have a form with 5 or so input fields for someone to enter data in, however I don't want each person to view all the data in everyone's test. Only the data for their test. Is there a way to have a...
3
by: franc sutherland | last post by:
Hello, I have a report which I filter using the me.filter command in the OnOpen event. Me.Filter = "OrderID=" & Forms!variable_form_name! Me.FilterOn = True I want to be able to open that...
5
by: phill86 | last post by:
Hi, I have a form that I have applied a filter to by using combo boxes which works fine. Is there a way to apply that filter to the forms underlying query Here is the code that I use to...
10
by: edgalljr | last post by:
I have a Button on a form that filters on 2 fields using the following code: Private Sub cmd_NavyDue_Click() With Me .FilterOn = True DoCmd.ApplyFilter , " = 'NAVY' And >1" Me.OrderBy =...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...

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.