473,586 Members | 2,681 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Override form recordsource with filter

11 New Member
How does a form's FILTER criteria work? If I specify a query in the form's recordsource, and then in VBA specify a form filter criteria, does the filter criteria override what was originally specified in the recordsource query?

For example, in the form's recordsource, I have specified: SELECT * FROM tblA WHERE Account='12345' . Later in VBA code, I specify filter = "Account='98765 ' filteron=true. Should the vba override the recordsource?

What if I specify a criteria for the filter that's not in the recordsource? Does it get appended to the recordsource, or replace the WHERE clause in the recordsource.

I can't seem to prove anything one way or another, but I know that my recordsource isn't working right when I add the filter specification.

Thanks,

Gerry Goldberg
Jul 16 '10 #1
1 4460
OldBirdman
675 Contributor
VBA doesn't override anything. VBA allows you to set properties of objects, as well as manipulating objects.
Your object here is a form. The property RecordSource you are setting to "SELECT * FROM tblA WHERE Account='12345' ". I would assume that this means that you have a RecordSource consisting of one record.
The Filter property of a form applies that filter to the form's RecordSource property. In this case, the result will be an empty recordset. I would expect errors such as 'No current record'.
If you are always going to 'know' the Account, then RecordSource = tblA would work, and the record shown would be the one specified with Filter = '12345' or Filter = '98765'.
Jul 16 '10 #2

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

Similar topics

2
6672
by: Patrick Gonzalez | last post by:
Is it possible to use the built-in filter functions (ie. "Filter by Selection", etc..) when a form's recordsource has been set to a recordset object during the load event. When I try to do this, I receive the message "Cannot apply filter on one or more fields specified in the filter property". here is the code for the recordset creation: ...
1
2007
by: Steve Miles | last post by:
I've got a form with a combo box and begin/end dates. When any of the three are changed I set a subform's recordsource so the records returned are filtered based on the three fields. The syntax I'm using is: Me.{subform-name}.Form.RecordSource = "Select * from tbl..." ....including the three fields in the SQL Where clause. This method...
2
15429
by: Lauren Quantrell | last post by:
I am using a stored procedure as the recordsource on an MS-Access2000 form: Forms!frmName.RecordSource = "dbo.myStoredProcedure" The stored procedure creates a temp table #Contacts and then inserts matching KeyID values contacts into it. Then I use a union query in the same stored procedure to create the actual recordset. What I want to...
1
5101
by: Sunil Korah | last post by:
I am having some trouble with opening recordsets. I have used code more or less straight from the access help. But still I am getting some errors. I am unable to work out what exactly I am doing wrong. I had posted this earlier along with another problem. I got answeres for that, but not this one; so I am reposting, hoping someone would...
2
2834
by: cefrancke | last post by:
I have a form (no underlying record set) that has two separate sub-forms on it. Each sub-form has data from two different tables. Above each sub-form there is one unbound combo box with a SQL record source that returns an ID field and a Text field. Next to each combo box is two buttons, one that 'Applys' the filter of the sub-form to the...
3
1781
by: Alan | last post by:
I'm having brain fade today... Can the recordsource in a Form's properties do more than one select statement based on criteria? On a popup subform I'm trying to display matching records from a table if MarketPlaceID on the parent form (frmCustomerOrders) matches MarketPlaceID from this table (tempOrders). If there are no matches I want it...
7
3493
by: Alan | last post by:
With earlier help from this group (thanks Ben!) I've ended up with this OnLoad code for my popup form: Private Sub Form_Load() If IsNull(!!) = True Then Me.RecordSource = "SELECT .* FROM WHERE !OrderID = Null" Else Me.RecordSource = "SELECT .* FROM WHERE !=!!"
5
7657
by: abolos | last post by:
Hi, I have an unbounded form with an unbounded text box. In the event On Open I have this code: Form.RecordSource"select last(kmprice) from tblmilageprice". The question is: How can I fill the text box with the result of thid code? Thanks, Abolos
2
3162
by: fastPace | last post by:
I created an SQL statement, left joining three tables. When I use the statement as the recordsource for my form in datasheetview, I cannot input data into any of the fields. Can anyone help me with this? Here is my SQL statement: strSQL = " SELECT tblAccounts.sNumber, tblAccounts.sName, tblAccounts.sType, tblUnAdj.sngUnAdjDR,...
2
10689
by: franc sutherland | last post by:
Hello, I am using Access 2003. I have a query which shows a list of club meetings sorted by date. This query is displayed in continuous forms, in a subform. I would like to select a month on the main form which is then used to filter the results for the meeting dates, perhaps by using monthname(month()). I have struggled to find the...
0
7912
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, 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...
0
7839
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...
0
8202
Oralloy
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. ...
0
8216
tracyyun
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...
0
6614
agi2029
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...
1
5710
isladogs
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...
0
3837
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...
1
2345
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
1
1449
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.