Solved

code transfer between forms

Posted on 2001-08-09
4
144 Views
Last Modified: 2010-05-02
Hi...

I have a form that consists of menuitems.  I have another form...(also visible) that has a bunch of settings.  The user can change these settings and there is a save button to save them.  If the user changes the settings and hits the menuitem without first hitting save....I would like to warn him that he will lose any unsaved data.  The problem is that the menuitem button is on another form. Plus there are a bunch of menuitems.  I would have to trap each button? What is the most efficient way of doing this?  I can do it with a bunch of globals but....I just think there gotta be a more efficient way.  

Heres what Ive got so far...

'MenuItem sub
public sub cmdMenuItem_Click()
If ChangeSettings.bIsSettingFormLoaded then
   If bIsDifferent then
     i = iSysMsg(MSG,iX,SetupChange)
'iSysMsg is an error msg generator located in another module.  MSG & SetupChange are also constants. iX is a local integer.

'Global Module to hold the changes
Type ChangeSettings_Type
bIsDifferent as boolean
bIsSettingFormLoaded as boolean
iMSGNumber as integer
end type

public ChangeSettings as ChangeSettings_Type


thanks

saki

0
Comment
Question by:sakibomber
4 Comments
 
LVL 12

Accepted Solution

by:
Preece earned 50 total points
ID: 6370389
You can use properties with forms.  For instance:


form1 general declarations
private pvsStatus as string

Public Property Let gpStatus(vData as string)
    pvsStatus = vdata
End Property




form2

cmdSave_Click()

'after validating and saving
form1.gpStatus = "saved"



When you are back on form1, check the value of the form scoped pvsStatus.  This variable could be of any datatype, just ensure that your let property reflects what datatype you are using.


Hope this helps!
Preece
0
 
LVL 8

Expert Comment

by:glass_cookie
ID: 6370916
Hi!

For the settings, you may want to create a public/global boolean variable.

Upon changing any settings, the boolean variable would change to True.

Upon saving, the boolean variable would change to False.

Upon exiting, if the boolean variable is True then send the warning message.

That's it!

glass cookie ; )
0
 
LVL 9

Expert Comment

by:Valliappan AN
ID: 6371240
Why do you wish to give a warning that the user lose changes, when still the form is active and/or visible?

do you mean to give the message when a Cancel button in the same form?

Cheers
0
 

Author Comment

by:sakibomber
ID: 6374284
cool thankx :)
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering 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

Suggested Solutions

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…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
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 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…

820 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