Click here to Skip to main content
11,709,536 members (52,628 online)
Rate this: bad
good
Please Sign up or sign in to vote.
See more: Access VBA
Okay, I know how to do this but it's just plain not working. I swear I've done this before. No matter how I vary the code I keep getting "you entered an expression that has an invalid reference to the property Form/Report"

I'm trying to set the RecordSource of one subform during the OnCurrent event of another subform on the SAME main form.

Main form: frmMain
Subform1: frmSub1 (in this form's OnCurrent event)
Subform2: frmSub2 (setting the source for this one)

in frmSub1's OnCurrent event:
Me.Parent!frmSub2.Form.RecordSource = "blah blah blah..."
'OR
Forms!frmMain!frmSub2.Form.RecordSource = "blah blah blah..."

If I do this in debug window:
?Forms!frmMain!frmSub2.Name

I get the result I expect. But if I do this in the debug window:
?Forms!frmMain!frmSub2.Form.RecordSource

I get the error noted above. Of course the error has nothing to do with the SQL string that I'm using to set the RecordSource. The error is saying it just plain doesn't like my form references. My eyes are starting to go nuts on this one. Can anyone see where the problem is?

Note that these subforms are NOT nested. They are separate subforms side by side on the same main form.

Thanks!
Posted 16-Oct-12 8:22am
Edited 16-Oct-12 8:40am
v5
Comments
Maciej Los at 16-Oct-12 14:35pm
   
Not clear. Please, be more specific...

1 solution

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 525
1 OriginalGriff 250
2 Peter Leow 219
3 Maciej Los 185
4 Mika Wendelius 160
0 OriginalGriff 9,428
1 Sergey Alexandrovich Kryukov 9,037
2 CPallini 5,189
3 Maciej Los 4,991
4 Mika Wendelius 3,856


Advertise | Privacy | Mobile
Web03 | 2.8.150819.1 | Last Updated 9 Nov 2012
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100