473,323 Members | 1,589 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,323 software developers and data experts.

Sharing data between forms

I have a form, call it SearchCriteria, which opens another form using this
code:
Dim frmResults As New SearchResults()

frmResults.ShowDialog()

In the SearchCriteria form the users specify, well, the criteria for
conducting a search. SearchResults should use that criteria to query the
database and then display the results. How do I pass the criteria from
SearchCriteria to SearchResults?

Much obliged.


Nov 20 '05 #1
5 1080
* "Geoff Pennington" <pe*********@stic2.com.NO!SPAM!> scripsit:
I have a form, call it SearchCriteria, which opens another form using this
code:
Dim frmResults As New SearchResults()

frmResults.ShowDialog()

In the SearchCriteria form the users specify, well, the criteria for
conducting a search. SearchResults should use that criteria to query the
database and then display the results. How do I pass the criteria from
SearchCriteria to SearchResults?


Add a public property to 'SearchResults' of the type of the search
criteria. Set this property after instantiating 'SearchResults' and
before showing the search results form.

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>
Nov 20 '05 #2
OK, thanks, that works. Out of curiousity, is there a way to go in reverse,
that is, could 'SearchResults' reference a public property in
'SearchCriteria'? Seems like it should, but I don't know how 'SearchResults'
can get a reference to the form that opened it.
"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:%2******************@TK2MSFTNGP09.phx.gbl...
* "Geoff Pennington" <pe*********@stic2.com.NO!SPAM!> scripsit:
I have a form, call it SearchCriteria, which opens another form using this code:
Dim frmResults As New SearchResults()

frmResults.ShowDialog()

In the SearchCriteria form the users specify, well, the criteria for
conducting a search. SearchResults should use that criteria to query the
database and then display the results. How do I pass the criteria from
SearchCriteria to SearchResults?


Add a public property to 'SearchResults' of the type of the search
criteria. Set this property after instantiating 'SearchResults' and
before showing the search results form.

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>

Nov 20 '05 #3
You can pass an object through the Constructor of the
second form, and created a local reference to it there.
then as you change data, it is getting changed on both.

Private object as MyClass

Public Sub New(ByVal objFromFrm1 as MyClass)

object = objFromFrm1
End Sub

Private SomSub
' Value will get changed in the object on both forms
' as objects work like pointers
object.value = Somedata

End Sub

-----Original Message-----
OK, thanks, that works. Out of curiousity, is there a way to go in reverse,that is, could 'SearchResults' reference a public property in'SearchCriteria'? Seems like it should, but I don't know how 'SearchResults'can get a reference to the form that opened it.
"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in messagenews:%2******************@TK2MSFTNGP09.phx.gbl. ..
* "Geoff Pennington" <pe*********@stic2.com.NO!SPAM!> scripsit:
> I have a form, call it SearchCriteria, which opens another form using
this
> code:
> Dim frmResults As New SearchResults()
>
> frmResults.ShowDialog()
>
> In the SearchCriteria form the users specify, well,
the criteria for > conducting a search. SearchResults should use that criteria to query the > database and then display the results. How do I pass the criteria from > SearchCriteria to SearchResults?


Add a public property to 'SearchResults' of the type of

the search criteria. Set this property after instantiating 'SearchResults' and before showing the search results form.

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>

.

Nov 20 '05 #4
"Geoff Pennington" <pe*********@stic2.com.NO!SPAM!> wrote in message
news:ep**************@TK2MSFTNGP11.phx.gbl...
In the SearchCriteria form the users specify, well, the criteria for
conducting a search. SearchResults should use that criteria to query the
database and then display the results. How do I pass the criteria from
SearchCriteria to SearchResults?

If you don't already know about this, you will probably benifit greatly from
reading about the SmallTalk Model-View-Presenter pattern. Do a search on
google for "Model View Controller" or "Model View Presenter", I can't even
begin to explain how much this concept has helped my OOP skills!
~
Jeremy

Nov 20 '05 #5
* "Geoff Pennington" <pe*********@stic2.com.NO!SPAM!> scripsit:
OK, thanks, that works. Out of curiousity, is there a way to go in reverse,
that is, could 'SearchResults' reference a public property in
'SearchCriteria'? Seems like it should, but I don't know how 'SearchResults'
can get a reference to the form that opened it.


You can pass the whole form (a reference to it) if you change the type
of the property to the form's type and set the property to 'Me' in the
calling form.

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>
Nov 20 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Paul Schouten | last post by:
I was wondering if anyone could help me with this... I am having problems sharing data between child forms. the setup is as follows: mainFrm <--- MDIForm |----> ViewFrm <----ChildForm |---->...
6
by: varlagas | last post by:
We disabled the antivirus software but the problem persists. Any clues? Many thanks in advance! Panagiotis Varlagas ======================================================================= ...
2
by: Red Green | last post by:
I am trying to switch to C# from Delphi and I am having some trouble finding some information. What I need to do should be simple but I have been through a dozen books and done web searches that...
3
by: Robert W. | last post by:
I'm embarking on a project that will have both a desktop application and a Pocket PC application. It seems logical to have as much code as possible sitting in a shared project, which would be...
2
by: Mervin Williams | last post by:
I am using Infragistics UltraWebTab (a tab folder control for ASP.NET). My tab folder control will include five tab pages with a separate web form on each, and these web forms will share data. ...
1
by: Tod Birdsall, MCSD for .NET | last post by:
Hi All, I have two ASP.NET applications which I am trying to have share forms authentication. But I am running into problems. App A is an ASP.NET 2.0 Beta 2 application. App B is an ASP.NET...
3
by: Chris Thunell | last post by:
I have 2 forms, on 1 form i use the wizards to create a strong typed dataset with tables from an SQL database... and from that i can do stuff like: me.daEmployee.fill(me.dataset11.tblEmployee) ...
11
by: Nick | last post by:
Hello, Please pardon my ignorance as this is something I should know, but I'm a little unclear. I have an MDI based app. It is setup so the user opens a file and the main child form is created....
1
by: Bob Alston | last post by:
Having problems sharing an Access database on a Windows 2000 PC. The other PC is windows 98 (as I recall) but NOT windows 2000! The 2nd PC has a shortcut to the MDB on the primary PC. The MDB...
9
by: kirk | last post by:
I have program.cs, my "main" form and then a "settings" form. My "main" form existed for awhile and I had constants, instantiations, properties, etc within it created. I went to create my...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.