Results 1 to 7 of 7
  1. #1
    qwerty is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Oct 2018
    Posts
    91

    The object doesn't contain the automation object.

    I am using a single text box to filter numbers from two fields in a query, and I am receiving the following error when testing. My textbox name is TxtSpec, Query Name = QueryForm, and Field Names PopMin and PopMax. Also, what do I add to the code if left blank show all data?



    My code is written =[QueryForm]![PopMin,PopMax]=[TxtSpec]=[«Expr»]>50<500

  2. #2
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,927
    think you need to provide a more detailed explanation

    where is the code? a query a control? in VBA?

    field names should not have non alphanumeric characters - PopMin,PopMax

    what is the code supposed to do?

  3. #3
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,652
    That's the textbox control source? For starters, you can't refer to query values that way, unless the query is the record source of the form. The expression doesn't make sense to me. In words, what are you trying to accomplish?
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  4. #4
    qwerty is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Oct 2018
    Posts
    91
    Quote Originally Posted by pbaldy View Post
    That's the textbox control source? For starters, you can't refer to query values that way, unless the query is the record source of the form. The expression doesn't make sense to me. In words, what are you trying to accomplish?
    The query is the record source for the form. What I want to accomplish is using a single text box to filter numbers from two fields in a query.

  5. #5
    qwerty is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Oct 2018
    Posts
    91
    Quote Originally Posted by Ajax View Post
    think you need to provide a more detailed explanation

    where is the code? a query a control? in VBA?

    field names should not have non alphanumeric characters - PopMin,PopMax

    what is the code supposed to do?
    Sorry apparently what I am using is a macro expression. Didn't realize it is different from sql.

    If the value is left blank it is just going to show all values.


    The code suppose is filter numeric data in two fields. It's only bird population based on nearest number you enter the in textbox. There are two fields popmax and popmin. The form is getting its data from a query.

    My form is linked to the Query.

  6. #6
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,927
    regret I don't use macros, so no idea if your construct is macro correct or not

  7. #7
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,652
    I don't regret that I don't use macros either.

    If you want to switch to VBA, sounds like you'd want this type of thing:

    Code:
    If Len(Me.TxtSpec & vbNullString) > 0 Then
      Me.Filter = "PopMin <= " & Me.TxtSpec & " AND PopMax >= " & Me.TxtSpec
      Me.FilterOn = True
    Else
      Me.Filter = ""
      Me.FilterOn = False
    End If
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 2
    Last Post: 07-20-2017, 07:20 AM
  2. Replies: 4
    Last Post: 02-06-2014, 12:55 AM
  3. Replies: 1
    Last Post: 12-27-2013, 01:59 PM
  4. Replies: 1
    Last Post: 07-02-2013, 08:41 AM
  5. Replies: 3
    Last Post: 11-02-2010, 10:14 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums