Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Values in other forms?

Posted on 2002-06-28
8
Medium Priority
?
152 Views
Last Modified: 2010-05-02
Hello,

   I have a program that is not MDI.  I have two forms one called frmMain and one called frmBrowser.  For some reason I can't access values in frmMain from frmBrowser.  For example, on frmMain there are 3 text boxes and 1 list box.  If I try to access the values of these from frmBrowser it doesn't work.  For example, frmMain.txtUsername is blank when I use it in frmBrowser.  If I select the first item in the listbox, frmMain.lstItems.selected(0) is false.  But the weird thing is I can access the properties.  I can get the values like frmMain.txtUsername.height and frmMain.lstItems.listcount.  Whats going on here, do the forms need to be MDI childs to be able to access each others values?

0
Comment
Question by:ingenito
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
8 Comments
 
LVL 43

Expert Comment

by:TimCottee
ID: 7116476
They don't need to be MDI children, but they do need to be loaded at the same time. Otherwise attempting to get the value of a control on another form will Load the other form implicitly (may not show it unless you specify this) and you will then get the default value of each control.
0
 
LVL 4

Expert Comment

by:gencross
ID: 7116485
I have tried a simple test of this myself and it seems to work fine.  Is there any other info you could provide?

You do not need to use MDI to do this.  It should work fine.
0
 
LVL 4

Expert Comment

by:gencross
ID: 7116488
I assume both of your forms are loaded?
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

Author Comment

by:ingenito
ID: 7116511
Yes, frmMain loads first, then frmMain calls frmBrowser and frmBrowser is trying to get data from frmMain.
0
 

Author Comment

by:ingenito
ID: 7116555
Ok,

I just did a simple test by creating a new project and it works fine.  The application I'm having trouble with was created with the wizard.  Could this have anything to do with it?

0
 
LVL 6

Accepted Solution

by:
ebosscher earned 300 total points
ID: 7117233
if you really can't make it work you can create a couple of public variables in a module and load the values into those before you show the browser form.

You can then reference the global variables on the browser form, rather than referencing the objects on the main form.

It's a work-around, not a solution, and I have no idea why that would be happening...
0
 
LVL 1

Expert Comment

by:alfanhendro
ID: 7120975
did you unLoad the frmMain when opening frmBrowser?
if so, change the statement "Unload Me" to "Me.Hide".
also, use "frmMain.txtUsername.Text" (notice the ".Text").

if it still cannot work, declare a public variable in frmMain. (this is what ebosscher suggest)

//put this in Declaration section
Public UserName as String

//put this under subroutine that open your frmBrowser
UserName=txtUserName.Text
frmBrowser.Show

//use the UserName, instead of txtUserName
//in your frmBrowser, eg.
Msgbox frmMain.UserName
0
 
LVL 49

Expert Comment

by:DanRollins
ID: 7964702
Hi ingenito,
It appears that you have forgotten this question. I will ask Community Support to close it unless you finalize it within 7 days. I will ask a Community Support Moderator to:

    Refund points and save as a 0-pt PAQ.

ingenito, Please DO NOT accept this comment as an answer.
EXPERTS: Post a comment if you are certain that an expert deserves credit.  Explain why.
==========
DanRollins -- EE database cleanup volunteer
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

610 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question