Solved

Simple Ques on Variables

Posted on 1998-12-15
6
134 Views
Last Modified: 2010-05-03
Hi
how do i declare a variable in my logon screen so it holds the value i give it and then my menu form can see that value ?
i hav tried using the Public tempstatus as integer
but the variable when the app switches to the menu form looses the value
thanx
C
0
Comment
Question by:CraigLazar
6 Comments
 
LVL 13

Accepted Solution

by:
Mirkwood earned 10 total points
ID: 1450205
Login screen is most likely created as
Dim MyloginForm as new LoginForm
MyLoginForm.show

And you access the variable like
LoginForm.PublicVar

LoginForm and MyLoginForm are two instances of the same form now and therefor LoginForm.PublicVar <> MyLoginForm.PublicVar

Declare a public variable in your main form and set its value in the loginForm

Dim MyLoginForm as new LoginForm
Dim MyMainForm as new MainForm

Load MyLoginForm
Load MyMainForm

MyLoginForm.Show vbModal
MyMainForm.PublicVar = MyLoginForm.PublicVar
MyMainForm.Show





0
 
LVL 1

Expert Comment

by:slobstar
ID: 1450206
is it in the declarations section?
0
 
LVL 12

Expert Comment

by:mark2150
ID: 1450207
Start your project from a .BAS MODULE and all vars declared there will be GLOBAL to all forms. You have to tinker with the project properties screen to tell it to start in SUB MAIN

M

0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 4

Author Comment

by:CraigLazar
ID: 1450208
Hi Mirkwood
thanx for your response
i am not following your response clearly
this is what i hav done

'start up is my frmLogon
in Declarations i hav declared my variable
public TempStatus as integer

then according to the User nme and password i set tempStatus
..
..
.
..
Tempstatus = 1

'Then i call my menu form
load frmMenu
frmMenu.show

'I need tempstatus to hold its value in the menu form because i am disabling some of my menu options according to the value of Temstatus

i hope this will help, I do not know if it is the write way to do it . i tried Mark2150 suggestion and it still looses it'e value
thanx allot mate
C
0
 
LVL 13

Expert Comment

by:Mirkwood
ID: 1450209
put this code in sub main

sub main()
Dim MyLoginForm as new LoginForm
Dim MyMainForm as new MainForm

Load MyLoginForm
Load MyMainForm

MyLoginForm.Show vbModal
MyMainForm.TempVar = MyLoginForm.TempVar
MyMainForm.Show
end sub

Give both MainForm an LoginForm the tempvar variable as public

0
 

Expert Comment

by:ed209
ID: 1450210
You may also want to use vb's form properties like:

'Declarations
Private intValue As Integer

Public Property Get Status() As Integer
    Status = intValue

End Property

Public Property Let Status(val As Integer)
    intValue = val

End Property


The form variable will hold it's value as long as it is still in memory, so you can hide the form, but don't unload.
ed209
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
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…
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…

932 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

16 Experts available now in Live!

Get 1:1 Help Now