nested subform navigation

  • Thread starter forrest lyman via AccessMonster.com
  • Start date
F

forrest lyman via AccessMonster.com

i use three levels of forms in my application.
[main] > application logo, main navigation buttons
[subform1] > specific control buttons, user tips
[subform2] > datasheet
i do this to separate my format, controls, and data

i am having a problem with my controls on [subform1].

[subform1] includes the navigation buttons for [subform2], as well as a search function, etc.
when i test [subform1] alone all of the controls function as planned.
when i nest the completed [subform1] in [main] the navigation controls on [subform1] stop working with [subform2].
all of the rest of the controls continue to work (search function, etc.).

i have tried every method i have found of referencing the nested subform, but can't get the nav buttons to work. the cursor stays in the first field of the first record. what is even more confusing is that i disabled my error handler on the nav button code while debugging, and while the cursor is not moving vba appears to think it is. after cycling through the sample files i get the "you can not go to the specified record" error.

i have tried to use vbconstants
DoCmd.GoToRecord , , acNext
as well as pointing directly to the record i want
DoCmd.GoToRecord , , 4

is there a dao or ado solution?
 
A

Albert D. Kallal

I think you have a neat approach here, as then you can simply "drop in" your
sub-from1 with all the navigation buttons, and use that
for any form you create!!

The problem here is that how does ms-access know which form
DoCmd.GoToRecord , , acNext

I mean, what happens if you want the above to applies to sub-form1???

The most "clean" approach here is to simply add the features to subform2,
and then have sub-form 1 call them.

For example, you can create a PUBLIC Sub in sub-form2. If you declare the
sub as public, then this sub becomes a METHOD of the form2.

So, you place the following code in the subform2's module:

Public Sub MyMoveNext()

DoCmd.GoToRecord , , acNext

end sub

Now, in your sub-from1 code, to move to the next record...you go:

Me.Parent.subform2.form.MyMoveNext

So, as a general rule, just add the features and functions you want to
sub-form 2..and then call them from sub-form one...
 

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