Controlling another forms recordset

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I created a "Find" dialog box that can be used to control the recordset of
the calling form. I tried several ways to control the other forms recordset.
One attempt looked like this:

[main]!prjtrans.Form.Recordset.Find "Transmittal=" & TransmittalNo

and this:

Forms!main.Form.Recordset.FindNext "TransmittalNo=" & TransmittalNo

This did not either:

Forms.item("Main").Form.Recordset.FindNext "TransmittalNo=" &
TransmittalNo

However I did get it to work by making the parent form recordset object a
global. However, I prefer not to use globals if they can be avoided. Is
there a way?
 
On Fri, 26 Oct 2007 12:58:01 -0700, Leif

How do you know which form you need to control? Answer: its name
should have been passed into your dialog using the OpenArgs argument
of DoCmd.OpenForm.
Then you can write:
dim f as Form
'TODO: Insert test for existence of form here
set f = Forms(OpenArgs)

Once you have a form object, you use the Bookmark property to select a
record:
with f.recordsetclone
.findfirst "Transmittal=" & Me.TransmittalNo
if .NoMatch then
MsgBox "Aaarrrccchhh, value not found!"
else
f.Bookmark = .Bookmark
end if
end with

-Tom.
 
Back
Top