Ask Your Question

Close form + warn if record is unsaved using macro [closed]

asked 2013-08-01 12:02:25 +0200

this post is marked as community wiki

This post is a wiki. Anyone with karma >75 is welcome to improve it.


I am building a database and I'm using a switchboard. Opening a form is working with the macro I am using. But the problem is going back to the switchboard. The macro I'm using leaves the form open.

What I want the button to do is: 1. Check if there is an open, unsaved record and if so warn the user to safe his work 2. Close the form that is in use (name of the first form is GSM formulier) 3. Open the switchboard form (whitch is named Switchboard)

I am not sure if the closing and opening are in the right order or it is wiser to first open the switchboard and after that close the form ' GSM formulier' . What is your take on this?

the macro I am using for opening the form is:

Sub OpenSwitchboard
const sNewDocumentName="Switchboard" ' This opens the switchboard
End Sub

I am not a programming superhero so any help is welcome.

Many thanks


edit retag flag offensive reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by Alex Kemp
close date 2016-03-05 18:39:02.121572



Did you ever resolve this? I am currently trying to do the same...

bigpook gravatar imagebigpook ( 2014-10-30 16:11:54 +0200 )edit

1 Answer

Sort by » oldest newest most voted

answered 2014-10-30 16:36:29 +0200

bigpook gravatar image

I found this and it seems to work. The scenario is where I am using a switchboard to open forms. When I am done with the open form I click the button, the form closes, and I am back at the switchboard.

Change OpenFormAppointmentsAll to OpenFormSwitchboard Change DBDoc.FormDocuments.loadComponentFromURL("AppointmentsAll","_blank",0,Args()) to DBDoc.FormDocuments.loadComponentFromURL("switchboard","_blank",0,Args())

Sub OpenFormAppointmentsAll(Event As Object) Dim Form As Object Dim FormDoc AS Object Dim FormCollection As Object Dim DBDoc As Object Dim Args(1) As New

Form=Event.Source.Model.Parent FormCollection=Form.Parent FormDoc=FormCollection.Parent

Args(0).Name="ActiveConnection" Args(0).Value=Form.ActiveConnection Args(1).Name="OpenMode" Args(1).Value="open"

REM - to close the current form REM - just before the new one opens REM - get a reference to the current form REM - and then the controller for the form REM - and finally from that FRAME it is in REM - then close that thisComponent.CurrentController.Frame.close( true ) DBDoc.FormDocuments.loadComponentFromURL("AppointmentsAll","_blank",0,Args()) End Sub

edit flag offensive delete link more

Question Tools

1 follower


Asked: 2013-08-01 12:02:25 +0200

Seen: 1,161 times

Last updated: Oct 30 '14