Refrencing between forms

  • Thread starter Thread starter Chris Strug
  • Start date Start date
C

Chris Strug

Hi,

Just wondering if anyone can point me in the right direction.

I have created an unbound form which runs on an ADO recordset linked to SQL
server. This bit is fine, retrieving, updating and otherwise handling the
data is absolutely fine. This form is called "FormA"

However I want to be able to search on this recordset. To do this I had in
mind a button which the user selects which displays a floating form (FormB).
From this the user enters the data they wish to search for, the field in
which they wish to look and a button to find the next item in the selected
field.

The problem is I don't know how to communicate between the two forms. How do
I reference the ADO recordset in FormA from FormB? Something that may
further complicate things is that I want the floating form to stay until the
user closes it...

How do I achieve this communication between the two forms? It isn't like I'm
referencing a control like a textbox, it's an actual ADO object I have
declared in the code behind the form....

Any assistance at all is gratefully appreciated.

Kind thanks

Chris.
 
hello Chris
first, to keep a form on top of another, but allowing the
focus to move between them as the user wishes to, is
accomplished by setting it's "popUp" property to true.
the second thing (finding an ado record in formA based on
something happenning in formB):
create a public sub in formA's module that searches the
recordset:
Public Sub SearchIt(fld1 As Long,fld2 As String...)
rs.Find "ID=" & fld1 & " And Name='" & fld2 & "'"....
End Sub

now use the button you've mentioned in formB to call this
sub, adding the data selected as parameters
Forms!formA.Form.SearchIt txtID, txtName(.....)

hope it helps,
good luck
Erez.
 
Erez said:
hello Chris
first, to keep a form on top of another, but allowing the
focus to move between them as the user wishes to, is
accomplished by setting it's "popUp" property to true.
the second thing (finding an ado record in formA based on
something happenning in formB):
create a public sub in formA's module that searches the
recordset:
Public Sub SearchIt(fld1 As Long,fld2 As String...)
rs.Find "ID=" & fld1 & " And Name='" & fld2 & "'"....
End Sub

now use the button you've mentioned in formB to call this
sub, adding the data selected as parameters
Forms!formA.Form.SearchIt txtID, txtName(.....)

hope it helps,
good luck
Erez.

Hi Erez,

Good idea! I was toying with the idea of making the ADO object a public
variable but I really didn't want to (you thank the guy who taught me Pascal
for that - still not comfortable with the idea of an end sub yet either :).
Your approach seems a lot more sensible anyway. I'll have a go and let you
know how I get on.

Chris.
 
Back
Top