Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Subform problem

Status
Not open for further replies.
Hi there,
Iwould lkie to filter records in a subform according to entries in two combo boxes on the main form.
My database is an inventory of different Items in different sections. I use the first combo box to select the section which works fine.I succeeded in doing it by typing the following in the following in its AfterUpdate event

DoCmd.ApplyFilter , "SectionID = Forms!Mainform!"
Me!Subform.SetFocus

I would also like to add another combo to select the item so that the records in the subform are filtered according to section and Item

thanking you
 
Put this in the AfterUpdate of your second box:

If Me.Filter="" Then
DoCmd.ApplyFilter , "SectionID = Forms!Mainform!"
Me!Subform.SetFocus
Else DoCmd.ApplyFilter, Me.Filter & " AND SectionID = Forms!Mainform!"
Me!Subform.SetFocus
EndIf

Let me know, if it worked...

Regards,
MakeItSo

Andreas Galambos
EDP / Technical Support Specialist
Bowne Global Solutions Wuppertal, Germany
(andreas.galambos@bowneglobal.de)
HP:
 
Hi Andreas,
First, I would like to thank you for the quick response.
Secondly, I would like to thank you for the brilliant idea, It worked after i changed SectionID to ItemID in the Else statment. I also added a LinkMaster/LinkChild Field according to ItemID.
Thanks again,

Julia

 
Hi,
In the subform, I would like the datasheet to show only the fields that apply to the selected Item. For example I would like the Telephone number field to appear only when I select Telephones in the Item combo box in the main form and not when I select Computers. Is this possible?

Thanking you,

Julia
 
Yes, a lot is possible in databases.. ;-)
What you need is query, that will give you the records.
Do the entries reflect the Field name in the table?
i.e. When you select "Telephones", is the corresponding field in the table also named "Telephones" a.s.o?

I guess this isn't the case, but anyway:
In order to exactly write down the code you need, I would require the table's name and the respective fields.
What choices do you have in that combo box?

Hope that wasn't too confusing now. :)

MakeItSo

Andreas Galambos
EDP / Technical Support Specialist
Bowne Global Solutions Wuppertal, Germany
(andreas.galambos@bowneglobal.de)
HP:
 
Hi Andreas,

The choices in the combo box are: Desktop computer, Laptop Printer, Dectphone, Deskphone, UPS

The tables name is equipment3 and has the following fields which apply to all the items listed above: Serial Number, Item, Manufacturer, Model, Department, Section.

The table also has the following fields, in brackets are the items that they apply to:

IP Address (Computer)
IPEI (Dect phone)
Telephone Number (Dectphone, Deskphone)
Computer Name (Desktop Computer, Laptop)
Rating (UPS)

Thanking You,

Julia

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top