Solved

Passing variables

Posted on 1998-11-06
5
181 Views
Last Modified: 2010-04-30
is it possible to pass variables from one form to another?
I can't seem to manage it. Any ideas?
0
Comment
Question by:SIMONBRATT
  • 3
5 Comments
 

Accepted Solution

by:
hess earned 50 total points
ID: 1443634
yes... use a module and declare your variables as public from within it.
0
 

Expert Comment

by:hess
ID: 1443635
if you have a futher questions just post them as comments
0
 
LVL 15

Expert Comment

by:ameba
ID: 1443636
Simple way:
Add to your Form1 declarations:
Public CustName As String
Public Points As Long
Public UpdForm As Form

Then you can use:
Form1.CustName="Simon"
Form1.Points=50
Set Form1.UpdForm=FormCU1
Form1.UpdForm.Show

---
Better way is to use Property Get/Let pair of procedures (or Get/Set)
Private m_CustName As String ' declarations

Public Property Get CustName() As String
    CustName=m_CustName
End Property

Public Property Let CustName(ByVal vNewValue As String)
    m_CustName=vNewValue
    Caption = "Customer: " & m_CustName
End Property
0
 

Author Comment

by:SIMONBRATT
ID: 1443637
Thanks, simple answer i guess but i'm a near beginner
0
 

Expert Comment

by:hess
ID: 1443638
in a module add this line
public x as integer

in any other code you can give x a value and all x's will have that value because now x is the same variable in all of you subs and functions
0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

829 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