PDA

View Full Version : Communicating between Forms and subforms



mud2
03-02-2005, 07:03 PM
I have a MainForm, FormMain, onto which I dragged and dropped two subforms. FormA and FormB. There is no table underlying the main form, and tables TableA and TableB are the basis for FormA and FormB. I also have a module...module1.
A control button on the main form calls a sub in the module. I want the module to write data to A text box in either of the rwo subforms.

This access program with All forms, tables, and module is in C:\ThreeForm

My statements in the module are:
[C:\ThreeForm]![FormA].Text1.SetFocus
[C:\ThreeForm]![FormA].Text1.Text = (Something)

I get error messages saying either that [C:\ThreeForm]![FormA] Can't be found, or that it isn't defined.

downwitch
03-03-2005, 06:43 PM
You don't refer to a file this way in Access. Its collections of objects--such as forms and queries and modules--are "inside" the file.

Forms!MyForm!MySubformControl.Form!MyTextBox.Value = "something"

will set a value in the MyTextBox control in a subform on a form called MyForm. Note that MySubformControl is the name of the control on MyForm--doesn't matter what the saved name of the subform object is. (Yes, I know that's a mouthful, no other way to explain it though.)

No need to set focus to a control to set its value.