473,758 Members | 6,734 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Why doen not this code work on filtering a form?!

Vic
Dear All,

I am getting the following error message :
"You cannot assign a value to this object" ("Me.filter =" is
highlighted)

I have two comboboxes (ByGenes and BySpecies)with lists in them on a
form. I want to be able to do filtering on a form by connecting two
criteria with a boolean expression (and). I want to get the two
criteria selected from the comboboxes then the form should be filtered
(Bygenes.value = 9 means "All" BySpecies.value s = 8 means "All" in
the combobox lists)
Private Sub ByGenes_AfterUp date()
If ByGenes.Value = 9 Or IsNull(Me.ByGen es) Then
Exit Sub
Else
Me.Filter = Me.Filter & " AND" & " GeneID = " & Me.ByGenes
Me.FilterOn = True
End If
End Sub

Private Sub BySpecies_After Update()
If BySpecies.Value = 8 Or IsNull(Me.BySpe cies) Then
Exit Sub
Else
Me.Filter = Me.Filter & " AND" & " SpeciesID = " &
Me.BySpecies
Me.FilterOn = True
End If
End Sub

What am I missing here?
Nov 12 '05 #1
2 1596
Is the forms AllowFilters property set to Yes (true)

Mike Storr
www.veraccess.com
"Vic" <la*****@ntlwor ld.com> wrote in message
news:52******** *************** ***@posting.goo gle.com...
Dear All,

What am I missing here?

Nov 12 '05 #2
On 26 Feb 2004 03:39:14 -0800, Vic wrote:
Dear All,

I am getting the following error message :
"You cannot assign a value to this object" ("Me.filter =" is
highlighted)

I have two comboboxes (ByGenes and BySpecies)with lists in them on a
form. I want to be able to do filtering on a form by connecting two
criteria with a boolean expression (and). I want to get the two
criteria selected from the comboboxes then the form should be filtered
(Bygenes.value = 9 means "All" BySpecies.value s = 8 means "All" in
the combobox lists)
Private Sub ByGenes_AfterUp date()
If ByGenes.Value = 9 Or IsNull(Me.ByGen es) Then
Exit Sub
Else
Me.Filter = Me.Filter & " AND" & " GeneID = " & Me.ByGenes
Me.FilterOn = True
End If
End Sub

Private Sub BySpecies_After Update()
If BySpecies.Value = 8 Or IsNull(Me.BySpe cies) Then
Exit Sub
Else
Me.Filter = Me.Filter & " AND" & " SpeciesID = " &
Me.BySpecies
Me.FilterOn = True
End If
End Sub

What am I missing here?

re: Me.Filter = Me.Filter & " AND" & " SpeciesID = " & Me.BySpecies

I can duplicate your error message ONLY if there is no filter already
in the Me.Filter. In other words the filter is blank.

However your code does works fine if, for example,
Me.Filter = "LastName] = 'Smith'".
Then adding the " and [SpeciesID] = " & Me.Byspecies
to the above filter is fine.

Nowhere in your code do you indicate Me.Filter already has an existing
string value.

Try adding an If .. Then to the procedure.

Private Sub ByGenes_AfterUp date()
If ByGenes.Value = 9 Or IsNull(Me.ByGen es) Then
Exit Sub
Else
If IsNull(Me.Filte r) Or Me.Filter = "" Then
Me.Filter = "Do an alternative filter here" '
Else
Me.Filter = Me.Filter & " AND" & " GeneID = " & Me.ByGenes
End If
Me.FilterOn = True
End If
End Sub

You can simplify your Me.Filter a bit by doing the following:
Me.Filter = Me.Filter & " AND GeneID = " & Me.ByGenes

--
Fred
Please only reply to this newsgroup.
I do not reply to personal email.
Nov 12 '05 #3

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

Similar topics

0
1612
by: Keith Shearer | last post by:
I'm having a bit of trouble, moving between controls, when filtering on a form. I'm using a continuous form. At the top I have 2 date fields. I want to filter the data specified between the two date fields ... The problem is ... I'm doing my filtering on the afterupdate event. So I type in a date and press TAB. The filter works and automatically refreshes the form, then the cursor does not move on to the next control, but comes back to...
19
3566
by: William Wisnieski | last post by:
Hello Everyone, I have a main form with a datasheet subform that I use to query by form. After the user selects two criteria on the main form and clicks the cmdShowResults button on the main form, the subform returns the records based on the two criteria. The criteria used on the main form are values selected in two list boxes. When the user clicks on the first list box (lstCollege), it returns values in the second list box...
0
1738
by: Scott Loupin | last post by:
I've got two databases with similar data in them (WestSide and EastSide). I've set up two identical reports that is filtered by date and the client name. I'm using one form to do the filtering. Currently, I've used queries to combine the two client lists, so when I open the combo box, I have many names I need to scroll through until I find the one I want. How can I use filtering to only see clients from one database or the other,...
1
5250
by: mstery | last post by:
I have a report generated via an ID selection made in a dropdown on a form. The report filters by an on click event in a preview report button on the form. Everything in the report, including subreports, filters perfectly, with the exception of a running sum DLookup field on the main report. This field looks up a value in a foreign table. I'm not clear where I'm supposed to be filtering this field, since it obviously isn't picking up the...
0
1021
by: Kristof | last post by:
I have created a framework with all our controls and forms we re-use in different projects. When we build the framework application we have a dll that we can reference in our project. When I create a form in my new project I can inhertis from a form in my framework thru the referenced dll. I will illustrate this with an example: I have a login form in the framework with 2 labels (User and pasword), 2 textboxen (user name and pasword)...
3
1992
by: Damon Grieves | last post by:
Hi I have a large table which I wanted to filter and then edit the selected record. I'm using a form with several pull down fields linked to lookup tables which correspond to fields in the large table. The user selects a number or category or All from the pull-down and this is used in a query, made up of the main table and the lookup tables with a suitable Iif statement to filter the query. So on the form there are several fields that...
2
1612
by: Katie | last post by:
I need to store a history of two fields in two seperate tables: Event - where the key is Event_ID Stage - where the key is Stage_ID The joins are: Main Table Event Table Stage Table My screen has:
8
6415
by: Ragbrai | last post by:
Howdy All, I have a query that is used for filtering results to be used in a combo box. The query needs to test fields from both a table and then unbound text boxes on the form that also contains the combo box. The fields I am working with are date fields that are formated as Short Date. I have written an IIF statement and placed it within the Criteria section of the Date field that I am trying to filter by. The current IIF statement works...
8
23816
by: Simon | last post by:
Dear reader, The syntax for the VBA code to change the RowSource of a Form is: Forms!FormName..RowSource = "TableOrQueryName"
0
9317
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,...
0
10090
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. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9758
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 choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8759
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 launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7310
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 instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6580
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();...
0
5190
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...
0
5343
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3844
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.