Refer to subform

snowsride

Registered User.
Local time
Today, 17:56
Joined
Nov 29, 2001
Messages
33
I have a Main form with two subforms Sub1 and Sub2.

I want to set the RecordSource of Sub2 from the OnGotfocus event on Control1 on Sub1.

My code is:

Dim intCtrl as integer
Dim strSQL as string

intCtrl = Me.Control1
strSQL = "Select * from MyTable where Id = " & strSQL
Forms!Main!Form!Sub2.RecordSource = strSQL
Forms!Main!Form!Sub2.RecordSource.ReQuery

When Control1 gets the focus I get an error Runtime error 2465 Access can't find the field 'Form' referred in your expression.

Have tried many permutations but no luck.

Grateful for help.
 

Users who are viewing this thread

Back
Top Bottom