Complicated (?) form-subform problem

J

Jen

....well, complicated to me at least!! (I have x-posted this to another non-MS
forum, so I apologize if you've already seen it).

I have a form (Form1) that contains a subform (Subform1). The subform is in
datasheet view, and I want to add a new field to it that holds notes - a memo
field. This won't work well in datasheet view...I want to be able to make the
box bigger so I can see a lot of its contents at once. So, I want to add
another box onto the main form that shows the notes associated with the
currently selected record in Subform1.

So basically, what I think I want is Form1, with Subform1 in datasheet view,
and another subform (Subform2) showing the notes associated with the current
record in Subform1. [Note: at first I did this using a popup form for the
Notes field, which worked fine, but we decided it would be preferable to have
it as a box on Form1.] Not sure if it's clear from the above explanation, but
Subform1 and Subform2 both have the same table as their datasource.

I'm pretty sure I need to use the OnCurrent event of Subform1 to make the
contents of Subform2 change as the selected record is changed. The problem
I'm having is that I can't get the syntax right for referring to Subform2. My
code on OnCurrent for Subform1 was:

Private Sub Form_Current()
Me![Subform2].Form!mmoNotes.Requery
End Sub

I also tried .Refresh but neither works. I was getting a syntax error when I
try to open Form1.

I read another couple of articles and tried this:

Private Sub Form_Current()
Forms!Form1![Subform2].Form!mmoNotes.Requery
End Sub

And now I'm getting a different error - "Run-time error '-2146500594
(8000f000e)': Method 'Form' of object '_Subform' failed.

Any suggestions or advice on how best to do this would be much appreciated.
I haven't done much work with subforms other than basic form-subform pairs,
so this is a bit new and confusing for me.

Thanks!!
Jen
 
R

RuralGuy

...well, complicated to me at least!! (I have x-posted this to another
non-MS forum, so I apologize if you've already seen it).

I have a form (Form1) that contains a subform (Subform1). The subform is
in datasheet view, and I want to add a new field to it that holds notes
- a memo field. This won't work well in datasheet view...I want to be
able to make the box bigger so I can see a lot of its contents at once.
So, I want to add another box onto the main form that shows the notes
associated with the currently selected record in Subform1.

So basically, what I think I want is Form1, with Subform1 in datasheet
view, and another subform (Subform2) showing the notes associated with
the current record in Subform1. [Note: at first I did this using a popup
form for the Notes field, which worked fine, but we decided it would be
preferable to have it as a box on Form1.] Not sure if it's clear from
the above explanation, but Subform1 and Subform2 both have the same
table as their datasource.

I'm pretty sure I need to use the OnCurrent event of Subform1 to make
the contents of Subform2 change as the selected record is changed. The
problem I'm having is that I can't get the syntax right for referring to
Subform2. My code on OnCurrent for Subform1 was:

Private Sub Form_Current()
Me![Subform2].Form!mmoNotes.Requery
End Sub

I also tried .Refresh but neither works. I was getting a syntax error
when I try to open Form1.

I read another couple of articles and tried this:

Private Sub Form_Current()
Forms!Form1![Subform2].Form!mmoNotes.Requery
End Sub

And now I'm getting a different error - "Run-time error '-2146500594
(8000f000e)': Method 'Form' of object '_Subform' failed.

Any suggestions or advice on how best to do this would be much
appreciated. I haven't done much work with subforms other than basic
form-subform pairs, so this is a bit new and confusing for me.

Thanks!!
Jen

Hi Jen,

Are you using the Master/Child link fields on SubForm1? If so, put the
same child linking field on SubForm2 but make it invisible and/or put it
behind the TextBox you will display the memo field in. Then use the same
Master/Child linking as SubForm1. No additional code anywhere! Everything
you want to happen will just happen! :)

hth
 
J

Jen

Hi RuralGuy,

Thanks so much - I did what you suggested, and that has gotten rid of all
the error messages and I can now see the Notes (memo) field for the first
record in Subform1. But when I click on a different record in Subform1,
Subform2 still doesn't refresh. Any other suggestions?

Jen
 
S

Steve Schapel

Jen,

With all due respect to RuralGuy, I think he misunderstood your question.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top