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.ApplyFilt er , "childid='" & Form_SearchF.Te xt1 & "'"
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.
2 11258
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.ApplyFilt er , "childid='" & Form_SearchF.Te xt1 & "'"
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.ApplyFilt er "childid=" & Form_SearchF.Te xt1
If you need to deal with both data types, you could do it like this: -
If IsNumeric(Me!childid) then
-
DoCmd.ApplyFilter "childid=" & Form_SearchF.Text1
-
Else
-
DoCmd.ApplyFilter "childid='" & Form_SearchF.Text1 & "'"
-
End If
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.ApplyFilt er "childid=" & Form_SearchF.Te xt1
If you need to deal with both data types, you could do it like this: -
If IsNumeric(Me!childid) then
-
DoCmd.ApplyFilter "childid=" & Form_SearchF.Text1
-
Else
-
DoCmd.ApplyFilter "childid='" & Form_SearchF.Text1 & "'"
-
End If
Thank you very much puppydogbuddy. It works well right now.
I appreciated your quick respond.
Sign in to post your reply or Sign up for a free account.
Similar topics |
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 , "bookref = forms!frm_trailers!txt_find_bref" This works
fine but I would like to change the filter property to Like instead of
equals due to some of the booking references being very long.
I've tried DoCmd.ApplyFilter , "bookref like " *...
|
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 a form that have the same effect as the "Filter by Form", "Apply Filter" and "Remove Filter" Buttons on the access toolbar. Help would be muchly appreciated. Cheers.
In the Click() Event of 3 Command Buttons, place the following code:
Code: (...
|
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 error.
I click Ok and the report opens.
I look in the design view and the filter is there but the IN equals
"" (it is blank, the values are not in there)
|
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
'dollars'. Using the "backend" of this table I can filter the numbers
by right clicking and using Filter For: then enter 1 or 2 or 3 and
this will return results for all information that has 1 or 2 or 3 as a
number.
However, the problem I...
|
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: 111
Charge: 02
Circle: 04
| |
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 filter set up that every time a person opens the form it will only show the test they are working on. So, they can't edit or see anyone else's data. Is there a way of doing this. I tried some with macros but I haven't used them before and can't...
|
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 report, filtered, from different
forms. How do I carry the name of the current form into the
|
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 filter the form
On Error GoTo Error_EquipFilter
|
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 = " DESC"
Me.OrderByOn = True
End With
End Sub
This works fine. However, I also want to filter on a field in a Subform when no record exists (or Is Null).
|
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: 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: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
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: 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: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |