Solved

Passing variables

Posted on 1998-11-06
5
178 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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
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…
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…
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…

758 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

22 Experts available now in Live!

Get 1:1 Help Now