-
data and multiple forms
I am developing an application that requires multiple froms.
I plan on having a Visible=false form that will have all of my data objects.
The grids on the other forms will need to access this data. I have been
able to
duplicate the example code given by MS but when I move the data objects and
update the subroutine to point at the data object on the invisible frame,
I get
no data.
This is what I have:
----------------------------------------------------------
Private Sub cmdMain_Click()
Unload Me
frmMain.Visible = True
End Sub
Private Sub cmdRefresh_Click()
Unload Me
Me.Visible = True
End Sub
Private Sub cmdSelectBatch_Click()
Unload Me
frmEditBatch.Visible = True
End Sub
Private Sub Form_Load()
frmHiddenData.Data1.RecordSource = ""
frmHiddenData.Data1.DatabaseName = "biblio.mdb"
DoSql
frmHiddenData.Data1.Refresh
MSFlexGrid1.Refresh
End Sub
Public Sub DoSql()
Dim mysql$
mysql$ = "SELECT "
mysql = mysql & "Publishers.[Company Name], "
mysql = mysql & "Authors.Author, "
mysql = mysql & "Titles.Title "
mysql = mysql & "FROM Authors INNER JOIN "
mysql = mysql & "(Publishers INNER JOIN ([title author] INNER JOIN Titles
ON [title author].ISBN = Titles.ISBN) ON Publishers.PubID = Titles.PubID)
"
mysql = mysql & "ON Authors.Au_ID = [title author].Au_ID "
mysql = mysql & "WHERE Authors.Au_ID < 30 "
frmHiddenData.Data1.RecordSource = mysql
End Sub
----------------------------
If I can get this to work, then I am sure that I can get the application
to work with the real data.
Part 2:
Will I be able to put data from one form into lables and text boxes on another?
Thank you.
-Mark
-
Re: data and multiple forms
Hi,
Couple things. First, why are you hiding forms and such? Not only are you
taking up a lot of memory and resources, but you are slowing your app down
as well. Why not create recordsets or even views for each form that are
called when a form is loaded and shown? Is there a specific reason you are
using this style? It would be much easier and much faster if you just
called the data you need for that specific form as needed. You can have
specific recordsets or queries populate a form when it is loaded and you
would not have to load so much data or try and remember where everything
goes.
In terms of what you are trying to and the code you supplied, I did not see
anything that told your data where to go. For example, you are loading
data and creating a hard coded query yet you are not telling the data where
you want it to appear from what I see. This applies to both the form and
the actual controls.
For example you said that you are hiding forms in the background. Let's
say you have two forms both with some text boxes and some grids on them.
Thus you might have form1 with text1 and grid1 and form2 with a text1 and
grid1. In this case, you need to tell VB and your data where to go
specifically because it does not know.
Having both forms loaded means VB sees two text1 objects and two grid1
objects. But it knows they are different only because they reside on
different container objects/forms. To send data to the proper text box
for example, you would need to have something like: form1.text1.text =
{data} and form1.grid1.value={data} and if you wanted that data to go to
form2, it would be form2.text1.text={data} and form2.grid1.value={data}
Unless you are using data bound controls that are connected to a data
control of some type, you need to tell your code where to put the data you
have retrieved. And in the case of using multiple hidden forms, you need
to also specifically state which container and object you want to have the
data placed.
--
Sincerely,
Todd B - CEO - Agendum Software
http://www.AgendumSoftware.com | Mailto:ToddB@AgendumSoftware.com
(608) 837-6736 (419) 821-9599
"skrobism" <skrobism@address.com> wrote in message
news:3a6dd544$1@news.devx.com...
>
> I am developing an application that requires multiple froms.
> I plan on having a Visible=false form that will have all of my data
objects.
>
> The grids on the other forms will need to access this data. I have been
> able to
> duplicate the example code given by MS but when I move the data objects
and
> update the subroutine to point at the data object on the invisible frame,
> I get
> no data.
>
> This is what I have:
> ----------------------------------------------------------
> Private Sub cmdMain_Click()
> Unload Me
> frmMain.Visible = True
> End Sub
>
> Private Sub cmdRefresh_Click()
> Unload Me
> Me.Visible = True
> End Sub
>
> Private Sub cmdSelectBatch_Click()
> Unload Me
> frmEditBatch.Visible = True
> End Sub
>
> Private Sub Form_Load()
> frmHiddenData.Data1.RecordSource = ""
> frmHiddenData.Data1.DatabaseName = "biblio.mdb"
> DoSql
> frmHiddenData.Data1.Refresh
> MSFlexGrid1.Refresh
> End Sub
>
> Public Sub DoSql()
>
> Dim mysql$
>
> mysql$ = "SELECT "
> mysql = mysql & "Publishers.[Company Name], "
> mysql = mysql & "Authors.Author, "
> mysql = mysql & "Titles.Title "
> mysql = mysql & "FROM Authors INNER JOIN "
> mysql = mysql & "(Publishers INNER JOIN ([title author] INNER JOIN
Titles
> ON [title author].ISBN = Titles.ISBN) ON Publishers.PubID = Titles.PubID)
> "
> mysql = mysql & "ON Authors.Au_ID = [title author].Au_ID "
> mysql = mysql & "WHERE Authors.Au_ID < 30 "
> frmHiddenData.Data1.RecordSource = mysql
> End Sub
> ----------------------------
>
> If I can get this to work, then I am sure that I can get the application
> to work with the real data.
>
> Part 2:
> Will I be able to put data from one form into lables and text boxes on
another?
>
> Thank you.
> -Mark
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks