Executing record operations from a Master Form to a Subform

M

Mark Asbell

Hi All

I have a single master form that is set up kind of like a web
page in that it has frame areas. Heading, Company
Logo, Main Work area - which is a subform, and there is a tree menu.
Selecting nodes in the tree menu changes the subform and hence the
operation being performed on the database.

I also have a frame on the master form that has a standard set of
buttons (I.e. Save, Delete, Move, Find, etc). My problem is that I
want these standard buttons to operate on the data in the subforms

Thus far I have tried:
1. Command from master form (format: DoCmd.GoToRecord ,
frmTreeMenu_SubForm.Name, acNext), but I get a 2489 error subform not
open
2. Calling a public routine (format: Call
frmTreeMenu_SubForm.Form.MoveNext) in subform. For the MoveNext
action, the routine executes, but I get a 2105 error - cant move to
specified record

Any help or ideas greatly appreciated
Mark
 
A

Albert D. Kallal

You have two choices:

1), make sure you move the focus to the subform *control*..and then execute
the move command

eg:

Me.child1form.SetFocus
DoCmd.GoToRecord acActiveDataObject, , acNext

The above does work quite well, but my spider sense does NOT like having to
use a focus switch.

2)

You can also put some code in the subform that moves to the next record such
as:


Public Function MoveNext()

On Error Resume Next
Me.Recordset.MoveNext

End Function

The above code would be placed in the SUB-FORM.

Then, in the main (parent form), you can reference the code/function like:

me.child1Form.Form.MoveNext

Note how you don't have to make a focus change. So, any public function
actually becomes a method of the form. And, of course, you can also declare
the function as a sub, and call it

Call me.Child1Form.Form.NameOfSub

So, you can build some custom public functions/subs...and call them..

if you don't want to write additional code in the sub-form code module, then
the first example of using the setfocus should work...
 
M

Mark Asbell

Thanks Albert

Was working on the subroutine modules but mine were using the Docmd object
which was not popular. Now just need to figure out how to work function for
'Find' and 'Filter'

Cheers
 

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