473,396 Members | 2,014 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,396 software developers and data experts.

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.values = 8 means "All" in
the combobox lists)
Private Sub ByGenes_AfterUpdate()
If ByGenes.Value = 9 Or IsNull(Me.ByGenes) Then
Exit Sub
Else
Me.Filter = Me.Filter & " AND" & " GeneID = " & Me.ByGenes
Me.FilterOn = True
End If
End Sub

Private Sub BySpecies_AfterUpdate()
If BySpecies.Value = 8 Or IsNull(Me.BySpecies) 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 1584
Is the forms AllowFilters property set to Yes (true)

Mike Storr
www.veraccess.com
"Vic" <la*****@ntlworld.com> wrote in message
news:52**************************@posting.google.c om...
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.values = 8 means "All" in
the combobox lists)
Private Sub ByGenes_AfterUpdate()
If ByGenes.Value = 9 Or IsNull(Me.ByGenes) Then
Exit Sub
Else
Me.Filter = Me.Filter & " AND" & " GeneID = " & Me.ByGenes
Me.FilterOn = True
End If
End Sub

Private Sub BySpecies_AfterUpdate()
If BySpecies.Value = 8 Or IsNull(Me.BySpecies) 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_AfterUpdate()
If ByGenes.Value = 9 Or IsNull(Me.ByGenes) Then
Exit Sub
Else
If IsNull(Me.Filter) 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
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...
19
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...
0
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. ...
1
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...
0
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...
3
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...
2
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 ...
8
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...
8
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
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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...
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...
0
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
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...

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.