Solved On Subform2 within Subform1 : Criteria for a lookup Query (to refer to a control on Subform1)

alan2013

Registered User.
Local time
Yesterday, 20:56
Joined
Mar 24, 2013
Messages
85
The scenario : I have a Subform1 set within a 'Main' Form. Within Subform1, I have a control (Field1_PK) and a Subform2. On Subform2, I have a combo that takes its data from a lookup Query. Within the Query, I want to be able to limit the records to ones that have a value set to that of the current Field1_PK value in Subform1.

In the Query, I have set the Criteria for Field1_FK (present in Subform2) to the following :

[Forms]![Main]![Subform1].[Form]![Field1_PK]

And that - in itself - seems to be working. The problem comes when, in Subform1, I navigate (simply using the built-in navigation button) to another record. The lookup doesn't update accordingly. Do I need to be creating some VBA code in the On Current Event, in order to force the lookup to update ?
TIA
 
Need to requery the combo.
However you could just link the fields in Master/Child fields.
 
of course you need to Requery your subform2 so that it updates it's Rowsource.
do it on the Current event of subform1.

Private Sub Form_Current()
Forms!Main!Subform.Form.Requery
End Sub

consider also using Link Master/Child Fields on subform2, therefore you can avoid using Criteria on the Query.
 
The issue seems to have been resolved now, with the addition of the following on Subform2 :

Private Sub Form_Current()
Me.Field1.Requery
End Sub

Regarding linking Master & Child fields : Field1_FK on Subform2 was already linked to Field1_PK on Subform1.

Reading back over my initial post, I didn't describe it well.
In any case, thanks Gasman and arnelgp
 

Users who are viewing this thread

Back
Top Bottom