Solved

code transfer between forms

Posted on 2001-08-09
4
141 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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
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…
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…

747 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

12 Experts available now in Live!

Get 1:1 Help Now