Results 1 to 13 of 13
  1. #1
    NadiaVKhan is offline Novice
    Windows 10 Access 2016
    Join Date
    Mar 2017
    Posts
    25

    Cannot Use Record Selectors in Filtered Form

    Cannot Use Record Selectors in Filtered Form



    Hello.

    I have an entry form that has about 20000 entries each uniquely identified by a "CaseNumber". I made a search button on the entry form to quickly find certain Cases by inputing a case number. This search, done via the OpenForm Macro, takes me to the exact case number that I specifcy. This is done by utilizing a Where Condition, which is:

    [CaseNumber] = FOrms![EntryForm][txtCaseNum]

    The problem with this is that it applies a filter. So If I hit the <next> button in the record selector, I am dropped to a blank case

    For example. Lets say I use my search function to open Case#19000. Next, I want to view #19001. If I click the "record selector next" button, I am taken to a blank case. What code would I need to create so that I am taken to #19001?

    Thanks

  2. #2
    aytee111 is offline Competent At Times
    Windows 10 Access 2013 64bit
    Join Date
    Nov 2011
    Location
    Nomad
    Posts
    3,936
    You would need to create a new filter - find the next record and filter on that. Or, the first filter can be => instead of just =.

  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,518
    Another option, if you're doing what I think you're doing:

    http://www.baldyweb.com/Bookmark.htm
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  4. #4
    NadiaVKhan is offline Novice
    Windows 10 Access 2016
    Join Date
    Mar 2017
    Posts
    25
    Quote Originally Posted by aytee111 View Post
    You would need to create a new filter - find the next record and filter on that. Or, the first filter can be => instead of just =.
    I tried adding => to the filter. But I was told "The OpenForm macro action has an invalid value for the Where Condition argument

  5. #5
    NadiaVKhan is offline Novice
    Windows 10 Access 2016
    Join Date
    Mar 2017
    Posts
    25
    Quote Originally Posted by pbaldy View Post
    Another option, if you're doing what I think you're doing:

    http://www.baldyweb.com/Bookmark.htm
    I came across this link early. Im not sure this is what I want however. I do not want to open a second form. I only want to work from the same form. Bascially, I want to type the CaseNumber into a search field on frmEntry. Then I want to be taken to that exact record (without it being a filter).

  6. #6
    Micron is offline Virtually Inert Person
    Windows 7 32bit Access 2007
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,737
    I only want to work from the same form.
    Suggest you use the FindRecord method of the DoCmd object. There are several parameters involved so you should look here and see if any are needed for your situation. Just remember to set focus to the field that contains the matching value that's in your search term textbox. It might be as simple as DoCmd.FindRecord Me.txtNameOfYourCriteriaTextbox
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  7. #7
    NadiaVKhan is offline Novice
    Windows 10 Access 2016
    Join Date
    Mar 2017
    Posts
    25
    Thank you. I believe this is more or less what I am trying to find. I input the code as

    DoCmd.FindRecord Me.txtSearch, acEntire, , acSearchAll, , , Me.txtNumCase

    Where Me.txtSearch is the unbound textbox where I am putting the number to search.
    and Me.txtNumCase is the field in the records I want to search through


    However, i receive runtimeerror2498 -- An expression you entered is the wrong data type for one of the arugments.

  8. #8
    Micron is offline Virtually Inert Person
    Windows 7 32bit Access 2007
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,737
    you have put me.txtnumcase in place of the FindFirst parameter? It is expecting a true/false value.
    The field reference doesn't belong anywhere in the method syntax.

  9. #9
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    Quote Originally Posted by NadiaVKhan View Post
    I came across this link early. Im not sure this is what I want however. I do not want to open a second form. I only want to work from the same form. Bascially, I want to type the CaseNumber into a search field on frmEntry. Then I want to be taken to that exact record (without it being a filter).
    Presuming the form is bound to the table, you could also use the combo box wizard, choosing the third option, "Find a record...".
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  10. #10
    NadiaVKhan is offline Novice
    Windows 10 Access 2016
    Join Date
    Mar 2017
    Posts
    25
    So should I just have used

    DoCmd.FindRecord Me.txtSearch, acEntire, , acSearchAll ??

  11. #11
    Micron is offline Virtually Inert Person
    Windows 7 32bit Access 2007
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,737
    Yes. Although since the parameters you've specified are defaults anyway, DoCmd.FindRecord Me.txtSearch should accomplish the same thing.
    Remember that the focus has to first be set to the control that's bound to the field you're going to search on.

  12. #12
    NadiaVKhan is offline Novice
    Windows 10 Access 2016
    Join Date
    Mar 2017
    Posts
    25
    Thanks. But I recieved the error:
    "A runtime error 2162. A macro set to one of the current field's properties failed because of an error ia find record action argument."

    Also, What did you mean by "The focus has to first be set to the control that's bound to the field you're going to search on."

  13. #13
    Micron is offline Virtually Inert Person
    Windows 7 32bit Access 2007
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,737
    Quote Originally Posted by NadiaVKhan View Post
    Thanks. But I recieved the error:
    "A runtime error 2162. A macro set to one of the current field's properties failed because of an error ia find record action argument."
    Also, What did you mean by "The focus has to first be set to the control that's bound to the field you're going to search on."
    The error is probably due to you not understanding thus not implementing the set focus thing. I mean that since you are using macros, you have to make the macro select the form control that is bound to the field you're going to use in the FindRecord method. If this were vba and was being done on a form, it would be txtTextboxName.SetFocus but I think the equivalent macro step is GoToControl.

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

Similar Threads

  1. Replies: 1
    Last Post: 01-13-2014, 12:11 AM
  2. Filtered Report from filtered datasheet form
    By gemadan96 in forum Reports
    Replies: 7
    Last Post: 01-03-2014, 05:12 PM
  3. Replies: 7
    Last Post: 07-30-2013, 07:51 AM
  4. More than One Record on filtered Continuous Form
    By Williams485 in forum Forms
    Replies: 3
    Last Post: 03-13-2013, 04:56 AM
  5. Replies: 1
    Last Post: 03-01-2012, 12:09 PM

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