FloIancu
FloIancu

Reputation: 2725

MS Access: Subform doesn't work, but the main form does

I have a form with a button that updates data in a table, form which works perfectly. However, when I add it as a subform on a tab paged form, it no longer does. Access prompts out asking for the [Forms]![MyForm]![textbox] variable, although it exists and is filled out. I'm guessing there's a different way to reference a subform.

Upvotes: 1

Views: 1967

Answers (2)

Olivier Jacot-Descombes
Olivier Jacot-Descombes

Reputation: 112762

The expression [Forms]![MyForm]![textbox] probably appears within the query used as RowSource of a ComboBox or ListBox on the subform. This subform is now no longer Forms!MyForm but

Forms!MainForm!MySubformControl.Form

I don't know the correct names, adapt them accordingly.

Change the expression to something like

Forms!MainForm!MySubformControl.Form!textbox
  • Forms is the collection of the open forms. (invariable)
  • MainForm is the name of the form with the tab control. (adapt)
  • MySubformControl is the name of the control containing the subform. (adapt)
  • .Form designates the subform itself. (invariable)
  • Finally textbox is your TextBox. (should be ok, otherwise adapt)

Upvotes: 0

Fionnuala
Fionnuala

Reputation: 91376

Refer to the name of the form, the name of the subform control, the form property and the name of the control (reference MVPs, MS ). You have MS Access 2010, so you can use the query design window and intellisense to build the relevant string, it will work put something like:

 [forms]![Gestiune]![SubformControlNameHere].Form![idInchirieri]

Upvotes: 3

Related Questions