MS Access master detail form

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

If I have to create a master detail form in access ie, Department and
Employees form where I enter the department code and based on that I have to
populate the employees list in a detail form below. In access where and how
do I write the query "select * from employees where departmentcode='01'" ?
and how do I assign the result to a detail without going thru the wizard ?
 
Madhuri said:
If I have to create a master detail form in access ie, Department and
Employees form where I enter the department code and based on that I
have to populate the employees list in a detail form below. In access
where and how do I write the query "select * from employees where
departmentcode='01'" ? and how do I assign the result to a detail
without going thru the wizard ?

A Subform control on an Access form has two properties Masterlink and
ChildLink that automatically filter the data in the subform for you. You do
not need to apply the criteria to the query as you state in your example.
All you need to do is enter "departmentcode" in those two properties.
 
If I have to create a master detail form in access ie, Department and
Employees form where I enter the department code and based on that I have to
populate the employees list in a detail form below. In access where and how
do I write the query "select * from employees where departmentcode='01'" ?
and how do I assign the result to a detail without going thru the wizard ?

Well... don't do it that way. You're making something quite easy much
more difficult!

Simply base a Form on the Department table; on it, put a Subform based
on the Employee table, using the Subform tool on the forms design
toolbar. I'd suggest using the wizard in this case - it's much less
intrusive and bossy than some of Microsoft's other wizards, and will
set up the subform correctly. If you don't wish to do so, just use the
subform tool and manually add the (preexisting, I presume) employee
form; set the Master Link Field and the Child Link Field properties of
the Subform control to [Departmentcode] to maintain the link. It's not
necessary to create a query in this case; the subform software does it
for you.

John W. Vinson[MVP]
 
Back
Top