how to go to a specific record on hidden form

ellenr

Registered User.
Local time
Today, 11:09
Joined
Apr 15, 2011
Messages
400
This shouldn't be this hard! Using a macro, how can I find and change a specific record in a hidden form? Each record has a unique line number that will be the search criteria. Thanks!
 
filter the form:
forms!myHiddenForm.filter = "[ID] = 874"
forms!myHiddenForm.filterOn = true

If its hidden ,whats the point of filtering it if you cant see it?
 
I did that, after which I was unable to goto new record because it kept remembering the filter. Think it is a bug in 2010 (read that somewhere as I was researching). Even if I closed the form and reopened it, it always used the filter. I am now in the process of trying to rewrite this very old macro in vba, but would prefer to be able to just goto the record in question in the macro.
 
When I rewrote it in vba I was able to remove the filter, and that let me goto a new record. Thanks.
 
One way to navigate a form's recordset in VBA is to expose a public method like...
Code:
sub GoToID(ID as long)
   with me.recordsetclone
      .findfirst "ID = " & ID
      if not .nomatch then me.bookmark = .bookmark
   end with
end sub
This routine uses the FindFirst method of a clone of the form's recordset to try and find a record based on criteria.

Then, if the form is open, external consumers can call the method using code like...
Code:
Forms!FormName.GoToID 1234
 

Users who are viewing this thread

Back
Top Bottom