GOTO Record Problem

D

DS

I have a form with a Listbox, when I click on this listbox it opens
another form with a group of records. This works fine. The problem is
that I have 2 criteria, MenuID and MenuCatID. If I keep the 2 criteria
it only brings up 1 record and I cn't cycle through theother records
because they aren't there. If I get rid of the MenuCatID all of the
records come up, which I want but, I want it to be on the MenuCatID from
the first form. Is there a way to do this. I need the second form
(Single Form) to come up on the MenuCatID but have all of the records
available. I tried the GoToRecord but that doesn't work.

In a nut shell I need to filter then go to...
Thanks
DS
 
D

DS

DS said:
I have a form with a Listbox, when I click on this listbox it opens
another form with a group of records. This works fine. The problem is
that I have 2 criteria, MenuID and MenuCatID. If I keep the 2 criteria
it only brings up 1 record and I cn't cycle through theother records
because they aren't there. If I get rid of the MenuCatID all of the
records come up, which I want but, I want it to be on the MenuCatID from
the first form. Is there a way to do this. I need the second form
(Single Form) to come up on the MenuCatID but have all of the records
available. I tried the GoToRecord but that doesn't work.

In a nut shell I need to filter then go to...
Thanks
DS


I tried this and it doesn't work...


DoCmd.GoToRecord , , acGoTo, MenuCatID = Me.Text49

DS
 
A

Albert D.Kallal

The first thing is to open the form with all of the filtered records. We
MUST get that working.

So, we will have

dim strF as string
strF = "MyFormName"
docmd.OpenForm strF,,,"MenuID = " & me!MenuID

(I have to guess how you fetch the MenuID, and your actual field names used)

at this point we got a form opened with all of the records. Now, lets move
the form to the record we want

forms(strF).RecordSetClone.FindFirst "MenuCatID = " & me!MyMenuCatID
forms(strF).BookMark = forms(strf).recordsetClone.BookMark

If fact, you likely can replace the above with

forms(strF).RecordSet.FindFirst "MenuCatID = " & me!MyMenuCatID

(note how above we used RecordSet in place of reocrdsetClone). (you need to
be using a2000 or later for the short version to work).

If you want a slightly more "modular" code approach, then you could also
"pass" the MenuCatID to the form via the open args and then move the above
code to the form (this would be a good idea, and then you can re-use the
form in more then one place, and not always have to re-peat the above code
to "move" to the record. So, you would simply use:

dim strF as string
strF = "MyFormName"
docmd.OpenForm strF,,,"MenuID = " & me!MenuID,,,me!MyMenuCatID

Then, in the 2 forms on-load event you would move to the record via

if isnull(me.Openarges) = false then
' a move to id was passed...lets move...
me.RecordSet.FindFirst "MenuCatID = " & me.OpenArgs

end if


So, give any of the above 3 possible solutions a try. I kind of like the
last one, as it a "better" coding practice to keep all of the code in the
2nd form, least in the future your copy the form, or move it to another
application.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top