user2385809
user2385809

Reputation: 1005

Refresh Query Subform with new criteria

In a form I have an unbound textbox. I then have a subform in a tab control. The subform is a query as follows:

SELECT PCR.PCRnum AS PCR, STIA.STIARev AS Rev, STIA.WP, STIA.STIAPDF.FileName AS PDF
FROM PCR INNER JOIN STIA ON PCR.PCRnum = STIA.PCR
WHERE (PCR.PCRnum=FindPCR.PCRsearched);

I am trying to build a little VB code that will on exit of the textbox run the query in the subform matching the value with PCR.PCRnum

I am new to access VB (I do a lot of Excel VB) and I am having troubles with the references.

Thank you!

Upvotes: 0

Views: 204

Answers (1)

pteranodon
pteranodon

Reputation: 2059

You won't need code if you use the LinkMasterFields and LinkChildFields properties of the subform control. In Design mode of your form, click once on the subform control. Look at the Properties list (F4). On the data tab try setting LinkMasterFields to PCRsearched and LinkChildFields to PCR. You might want to set FilterOnEmptyMaster to No if you want all records to show when your unbound textbox is empty. In any case, the subform will be refiltered whenever there is a change to the unbound text box.

Upvotes: 1

Related Questions