473,396 Members | 1,886 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.

Help with (Example Filtering on a Form).

5
Hi,

I've tried using this following code but I keep getting the following error:

Runtime Error 2448
You can't assign a value to this object.

Do you know what the problem may be?





CHAPTER 5 - FORM MODULE

Expand|Select|Wrap|Line Numbers
  1. Option Compare Database
  2. Option Explicit
  3.  
  4. Private Sub txtFindAccountCode_AfterUpdate()
  5.     Call CheckFilter
  6. End Sub
  7.  
  8. Private Sub txtFindCreationDate_AfterUpdate()
  9.     Me!txtFindCreationDate = IIf(IsDate(Me!txtFindCreationDate), _
  10.                                  Format(Me!txtFindCreationDate, "d mmm yyyy"), _
  11.                                  "")
  12.     Call CheckFilter
  13. End Sub
  14.  
  15. Private Sub cboFindAccountType_AfterUpdate()
  16.     Call CheckFilter
  17. End Sub
  18.  
  19. 'CheckFilter produces the new Filter depending on the values currently in
  20. 'txtFindAccountCode, txtFindCreationDate & cboFindAccountType.
  21. Private Sub CheckFilter()
  22.     Dim strFilter As String, strOldFilter As String
  23.  
  24.     strOldFilter = Me.Filter
  25.     'txtFindAccountCode - Text
  26.     If Me!txtFindAccountCode > "" Then _
  27.         strFilter = strFilter & _
  28.                     " AND ([AccountCode] Like '" & _
  29.                     Me!txtFindAccountCode & "*')"
  30.     'txtFindCreationDate - Date
  31.     If Me!txtFindCreationDate > "" Then _
  32.         strFilter = strFilter & _
  33.                     " AND ([CreationDate]=" & _
  34.                     Format(CDate(Me!txtFindCreationDate), _
  35.                            "\#m/d/yyyy\#") & ")"
  36.     'cboFindAccountType - Numeric
  37.     If Me!cboFindAccountType > "" Then _
  38.         strFilter = strFilter & _
  39.                     " AND ([AccountType]=" & _
  40.                     Me!cboFindAccountType & ")"
  41.     'Debug.Print ".Filter = '" & strOldFilter & "' - ";
  42.     'Debug.Print "strFilter = '" & strFilter & " '"
  43.     'Tidy up results and apply IF NECESSARY
  44.     If strFilter > "" Then strFilter = Mid(strFilter, 6)
  45.     If strFilter <> strOldFilter Then
  46.         Me.Filter = strFilter
  47.         Me.FilterOn = (strFilter > "")
  48.     End If
  49. End Sub
Sep 6 '07 #1
10 1619
NeoPa
32,556 Expert Mod 16PB
In the article itself (Example Filtering on a Form) is not the place to start a discussion or a question so I've moved your post as a question to the Access Forum.

I will try to get to this sometime today to see if I can answer your question.
Sep 6 '07 #2
NeoPa
32,556 Expert Mod 16PB
Having now looked at your question it seems you want me to debug your code without even letting me know where your error occurred. The error message helps - but without the line of code it appears in it doesn't mean much

Please provide the information I need so that I can try to help you.
Sep 6 '07 #3
Cat123
5
My apologies. The error occurs on Line 46

Me.Filter = strFilter

Having now looked at your question it seems you want me to debug your code without even letting me know where your error occurred. The error message helps - but without the line of code it appears in it doesn't mean much

Please provide the information I need so that I can try to help you.
Sep 6 '07 #4
NeoPa
32,556 Expert Mod 16PB
I was being Naive - I thought you'd posted your code.
I will need the code you're using as well as the line number the error occurrs on. We'll get there I'm sure - I just need the question.

*Edit - You're using the original code directly?
Sep 6 '07 #5
Cat123
5
I was being Naive - I thought you'd posted your code.
I will need the code you're using as well as the line number the error occurrs on. We'll get there I'm sure - I just need the question.
Here's the code I used.....

Expand|Select|Wrap|Line Numbers
  1. Private Sub cboFindTL_AfterUpdate()
  2.     Call CheckFilter
  3. End Sub
  4.  
  5. Private Sub cboFindSurname_AfterUpdate()
  6.     Call CheckFilter
  7. End Sub
  8.  
  9. Private Sub CheckFilter()
  10.     Dim strFilter As String, strOldFilter As String
  11.  
  12.      strOldFilter = Me.Filter
  13.  
  14.     If Me!cboFindSurname > "" Then _
  15.         strFilter = strFilter & _
  16.                    " AND ([Surname] Like '" & _
  17.                      Me!cboFindSurname & "*')"
  18.  
  19.  
  20.     If Me!cboFindTL > "" Then _
  21.         strFilter = strFilter & _
  22.                     " AND ([Team Leader]=" & _
  23.                     Me!cboFindTL & ")"
  24.  
  25.     If strFilter > "" Then strFilter = Mid(strFilter, 6)
  26.     If strFilter <> strOldFilter Then
  27.         Me.Filter = strFilter
  28.         Me.FilterOn = (strFilter > "")
  29.     End If
  30. End Sub
Sep 6 '07 #6
NeoPa
32,556 Expert Mod 16PB
If you can confirm that the error occurred on line #27 then I can look at it in more detail.
Sep 6 '07 #7
Cat123
5
I'm getting the error on line 27
Me.Filter = strFilter




Here's the code I used.....

Expand|Select|Wrap|Line Numbers
  1. Private Sub cboFindTL_AfterUpdate()
  2.     Call CheckFilter
  3. End Sub
  4.  
  5. Private Sub cboFindSurname_AfterUpdate()
  6.     Call CheckFilter
  7. End Sub
  8.  
  9. Private Sub CheckFilter()
  10.     Dim strFilter As String, strOldFilter As String
  11.  
  12.      strOldFilter = Me.Filter
  13.  
  14.     If Me!cboFindSurname > "" Then _
  15.         strFilter = strFilter & _
  16.                    " AND ([Surname] Like '" & _
  17.                      Me!cboFindSurname & "*')"
  18.  
  19.  
  20.     If Me!cboFindTL > "" Then _
  21.         strFilter = strFilter & _
  22.                     " AND ([Team Leader]=" & _
  23.                     Me!cboFindTL & ")"
  24.  
  25.     If strFilter > "" Then strFilter = Mid(strFilter, 6)
  26.     If strFilter <> strOldFilter Then
  27.         Me.Filter = strFilter
  28.         Me.FilterOn = (strFilter > "")
  29.     End If
  30. End Sub
Sep 6 '07 #8
Cat123
5
Hi,

When debugging if I hoover over the variable strFilter on line 26 I can see that it has an actual valid string. But on line 27 it just doesn't seem to want to assign that string to the form.filter property. Does this help at all?


I'm getting the error on line 27
Me.Filter = strFilter
Sep 6 '07 #9
NeoPa
32,556 Expert Mod 16PB
What type of field is [Team Leader]?
Is Me!cboFindTL of the same type?
Sep 6 '07 #10
NeoPa
32,556 Expert Mod 16PB
Hi,

When debugging if I hoover over the variable strFilter on line 26 I can see that it has an actual valid string. But on line 27 it just doesn't seem to want to assign that string to the form.filter property. Does this help at all?
That does help and confirms my fear that this is not a code issue as much as a design issue. I can't imagine why this might happen I'm afraid.

Have you downloaded the example DB and seen if that works on your system?

PS. Ignore questions in earlier post as this info takes us past there.
Sep 6 '07 #11

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

Similar topics

0
by: Suzanne | last post by:
Hello experts, I am a VBA newbie. Most of the tricks I apply to my applications I learn from here or google. I couldn't find a solution for the following two things, they both are related to...
3
by: Jason | last post by:
I am trying to filter records in a primary form based on records in related tables. The data in the related tables is being displayed in the primary form through subforms. To be more specific, I...
2
by: Luther | last post by:
I want to create a form that searches a table. The hard part is this, I'd like to have the available records filtered based on combobox selections. For example, if this were a vehicle database, I...
0
by: Patrick | last post by:
I'm working on a contact management application, and need a hand with one aspect... Here's what I want to create: ------------------------------------ A form split into two parts. There is a...
3
by: Liddle Feesh | last post by:
Hi, I have a table named "Person" in a MSDE (2000) database, and am building a search form comprising of search fields on the top section (forename, surname, telephonenumber, etc) which all...
3
by: Mike Jakes | last post by:
I hope that someone can offer a little advice on this one - I've searched the group but can't find an answer. I think that I'm doing something really stupid or missing something trivial, but see...
2
by: JUAN ERNESTO FLORES BELTRAN | last post by:
Hi you all, I am developping a python application which connects to a database (postresql) and displays the query results on a treeview. In adittion to displaying the info i do need to implement...
1
by: access baby | last post by:
Hi Below mention is the reply from Salad on my query i created a crosstab query and form not based on any table of qurey but this doesnt work . I somehow have missed something actually i have too...
3
by: plyable | last post by:
Hi there. I made a program that reads data from a device through a serial port which then displays it in a textbox. As the data comes out in ASCII form, I have to filter out the unnecessary parts for...
1
by: oneski | last post by:
help --- 403 You don't have permission Im trying to get a basic search to work on my website, but i keep getting a forbidden error come up. Im using WAMP5 server on a vista machine. The error file...
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...
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...
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
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.