Solved

code transfer between forms

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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
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…
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…

813 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

11 Experts available now in Live!

Get 1:1 Help Now