Here is what I am trying to accomplish:
Form 1
Form 2 (subform of Form 2)
Form 3 (subform of Form 3)This form has multiple records
showing in datasheet view.
(I am not using subform controls, the subforms are just
sitting in the main form, so no click is necessary).
Oh. "I'm not using subform controls, the subforms are..."
Then THEY ARE NOT SUBFORMS. I was assuming that when you said that you
were using a subform that you were in fact using a subform. My code
applies to Subforms, which is what you were asking about (or so I
thought).
So are you using a popup form, with code to open it or set focus to it
or what?
There is a field on Form 2 which is an autonumber - lets
call it client#. (The tables are in SQL Server so the
autonumber field does not have a value in it until the
record is closed).
Form 3 has the client# field in it - so that it relates to
Form 2. I have code which requeries Form 2 when Form 3
opens, then I need to have the client# automatically fill
in to all records in Form 3.
I have entered code:
Private Sub Form3_Enter()
Me.client#.Requery
Forms!Form1!Form2!Form3!client# = Forms!Form1!Form2!client#
End Sub
This works up to a point.
This should not work AT ALL, unless you're confusing me even more;
this syntax applies to Subforms on Subform controls - which you say
you are not using.
The client# only shows up in
the first record of Form3, not in any of the other records
showing.
Of course it does; a form (or subform) has only one active record, and
if you have not selected a record, that will be the first record.
You're doing this in a VERY strange way - filling Form3, and only
afterward filling in the Client#?
Just FWIW, if you're not in fact already doing so, I'd suggest using
Subform Controls with these subforms in them; and including Client# as
the Master/Child Link Field of the subform control containing Form3.
This will cause Form2 to be saved to disk (automatically, with no code
needed) when you setfocus to Form3, and will fill in the Client#
automatically - again, no code needed.