Consulting

Results 1 to 2 of 2

Thread: Communicating between Forms and subforms

  1. #1
    VBAX Tutor
    Joined
    Mar 2005
    Posts
    204
    Location

    Communicating between Forms and subforms

    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.

  2. #2
    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •