Using MS Access/Relating forms in VBA

Advertisement


Question
My knowledge of VBA is very basic.

This is the situation:
I've got a form (A) with specifications for a building project, with a subform (B) which gives a list of buildings belonging to this project. In Subform B I want to create a link to a new form C in which I can define types of rooms belonging to a building listed in subform B.

When I press the link/button to open form C for defining a NEW building, then form C most take the data from form A. So it opens a new form (C) which  gives the name of the project where the building belongs to.

I think this problem most be solved by directly using VBA. I hope my problem is clear, and every solution is welcome.

Answer
Hi

The easiest answer here is...

When opening form C, reference the fields you wish to use on form A

I.e.

Me.txtSomeField = Forms!frmFormA!txtSomeField

What's happening above is the value from Form A, txtSomeField is then inherited by form C, txtSomeField

You could use similar syntax in the Form_Open event of form C

HTH

rob

Using MS Access

All Answers


Answers by Expert:


Ask Experts

Volunteer


Rob Henderson

Expertise

I can answer most MS Access design questions. I also welcome questions on database design and implementation and VBA programming questions. I also have expierence in application design for all the Office components (Excel, Outlook, etc).

©2012 About.com, a part of The New York Times Company. All rights reserved.