?
Solved

Passing variables

Posted on 1998-11-06
5
Medium Priority
?
184 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
[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
  • 3
5 Comments
 

Accepted Solution

by:
hess earned 100 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

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.

Question has a verified solution.

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

Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses
Course of the Month11 days, 16 hours left to enroll

752 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