Solved

Value from another form

Posted on 2003-10-30
15
151 Views
Last Modified: 2010-05-03
In my first form (start.frm) there is a value FindStr. Can I use this value in anthoter form warning.frm?

In start.frm there is set a value FindStr.
If something is found, it opens warning.frm
How to show the value  FindStr from start.frm in warning.frm?

Jeffeny
0
Comment
Question by:harryv
  • 4
  • 4
  • 3
  • +2
15 Comments
 

Expert Comment

by:clangl
Comment Utility
If you create a Property in warning.frm and then warning.frm.FindStr=start.frm.FindStr may give you a quck solution.
0
 

Author Comment

by:harryv
Comment Utility
Hoi,

It gives an error on Start.frm.FindStr

Private Sub Form_Load()
Dim FindStr As String
Warning.frm.FindStr = Start.frm.FindStr
MsgBox "WARNING: " & FindStr, vbCritical
End Sub

What's wrong?
0
 
LVL 28

Expert Comment

by:vinnyd79
Comment Utility
Add a bas module and define FindStr as public:

' in a bas module
Public FindStr as string
0
 
LVL 5

Expert Comment

by:rajaamirapu
Comment Utility
If start is the name of the form
Use Start.FindStr
0
 
LVL 11

Expert Comment

by:dbrckovi
Comment Utility
Yes you can but you have to declare this value as property,   like this:      Public FindStr As String

Now it can be accessed from any form like:       Start.FindStr          and you can use this as any other variable.


P.S.    You dont have to write a form extension becouse it can make people confused.  Just saying that this is a form should be enough.
         
0
 
LVL 28

Expert Comment

by:vinnyd79
Comment Utility
Yes,but if you put "Public FindStr as string" in a bas module,then you can use FindStr on any form without specifying a form name in front.
0
 

Expert Comment

by:clangl
Comment Utility
If you are using VB 6 you need to define the Property
dim mFindStr as String
Public Property Get FindStr () as string
   FindStr =mFindStr
end Property
Public Property Let FindStr (newVal as string)
  mFindStr=newVal
end Property
0
What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

 

Expert Comment

by:clangl
Comment Utility
These Properties need to be defined in the Form
0
 

Author Comment

by:harryv
Comment Utility
Ok I have created a module1 (module1.bas) with the text

Public FindStr As String

But:

Private Sub Form_Load()
MsgBox "WARNING: " & Start.FindStr, vbCritical
End Sub

Gives an error on Findstr

Do I have to include the module?

?
0
 
LVL 5

Expert Comment

by:rajaamirapu
Comment Utility
remove start
0
 
LVL 28

Expert Comment

by:vinnyd79
Comment Utility
If you put it in a module,then just use this on your form:

Private Sub Form_Load()
MsgBox "WARNING: " & FindStr, vbCritical
End Sub

0
 
LVL 5

Expert Comment

by:rajaamirapu
Comment Utility
directly reference Findstr
0
 

Author Comment

by:harryv
Comment Utility
No value
0
 
LVL 28

Accepted Solution

by:
vinnyd79 earned 25 total points
Comment Utility
Make sure you are setting the value of FindStr on your start form.Also make sure you are not dimming FindStr on your forms because it will override the Public declaration in the module.
0
 

Author Comment

by:harryv
Comment Utility
Yes!!!
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
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…

772 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now