Solved

code transfer between forms

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

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

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
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…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
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…

867 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

15 Experts available now in Live!

Get 1:1 Help Now