Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

code transfer between forms

Posted on 2001-08-09
4
Medium Priority
?
149 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 12

Accepted Solution

by:
Preece earned 200 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
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…
Suggested Courses

715 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