473,769 Members | 3,755 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Returning Data from Modal Form

72 New Member
Hello,

This may seem really stupid, but what's the best way to return data from a Modal form??

It seems that Access uses a different Forms library to the other MS apps, and does not have the usual .Show member.

I have a form I have set as Modal in its Form properties. I have a Class module with properties (i.e. my data object). The form has a private instance of this class, and as options are selected and set on the form, the data is set in the object.

The form is initially called from some VBA code, and I want to be able to retrieve that object in the form after the user hits run.

Access appears to have only one way to open and display a modal form, using DoCmd.Open, where the acDialog option can be used to prevent code from continuing on until the form is closed.

The problem with this is of course that the single line command effectively loads a new instance of the form, runs it, and then closes and unloads it straight away when the user closes it, without ever creating a referrable instance in the code.

This means no data can be passed to the form before showing, and cannot be retrieved after the form has been closed.

With other VBA apps I could load the form, call some properties on the form first to populate the form, show it, and the code would not advance until it was hidden. But the form would not unload from memory, so the data was still retrievable afterwards.

It seems while Access has got the Load/Unload options, it only has the .Visible property, which of course does not stop the code from advancing until the form is hidden, so the calling code tries to continue on.

The only workaround I can think of is to have a DoEvents loop after the form becomes visible checking for a flag on the form to be set before continuing, with code on the form setting the flag on the press of a button. This seems like a clunky workaround to me.

Any help is appreciated.

Regards,
Rob.
Jun 15 '08 #1
7 17704
RuralGuy
375 Recognized Expert Contributor
Have you tried using global variables or maybe passing a control name in the OpenArgs argument?
Jun 15 '08 #2
FishVal
2,653 Recognized Expert Specialist
....
Access appears to have only one way to open and display a modal form, using DoCmd.Open, where the acDialog option can be used to prevent code from continuing on until the form is closed.
.....
Fortunately it is not the only option.
You may make form modal, anytime you like, setting its "Modal" property to True.

Regards,
Fish

P.S. You may find interesting this thread.
Jun 16 '08 #3
peridian
72 New Member
Fortunately it is not the only option.
You may make form modal, anytime you like, setting its "Modal" property to True.

Regards,
Fish

P.S. You may find interesting this thread.
Yes, I was aware of that, as I stated in my post. The problem is that simply setting that does not stop the code.

Have you tried using global variables or maybe passing a control name in the OpenArgs argument?
As much as I hate global variables, I suspect this is about the only way of doing this. I had hoped that the data manipulation could be encapsulated within the code and passed around correctly.

Thanks for your responses.

Regards,
Rob.
Jun 16 '08 #4
FishVal
2,653 Recognized Expert Specialist
Yes, I was aware of that, as I stated in my post. The problem is that simply setting that does not stop the code.
What for you want to stop code execution?

Kind regards,
Fish
Jun 16 '08 #5
peridian
72 New Member
What for you want to stop code execution?

Kind regards,
Fish
The reason for having the form be Modal is that it is for the user to supply options to a process.

The sequence goes:

1) Import data from sources.
2) Do some analysis and calculations
3) *Present user with options based on results*
4) Do output based on user options.

So I need to open the form to set data for the rest of the process to use.

The problem is that the options made available to the user will depend on the analysis, and the output will depend on the user options. So I need to be able to pass information to and from the form when opend/closed, but not allow the code in the background to carry on until the options have been chosen.

The alternative I've just considered is having an intermediate "save table" that makes the input and output available to both ends, but this is messy to me.

I'm planning on using a static property of the class object to make it available internally in the object calling the form, but accessible by the form without having to be passed the explicit instance of the object.

I know this would work in other languages, so I'll try it here.

Regards,
Rob.
Jun 16 '08 #6
FishVal
2,653 Recognized Expert Specialist
You may handle second form event in the first form module or you may call first form method/property from the second form module.

Regards,
Fish
Jun 16 '08 #7
ADezii
8,834 Recognized Expert Expert
How about?
  1. Opening the Form in Hidden Mode
  2. Assign values to Form Fields while the Form is Hidden
  3. Make the Form visible at the appropriate time
    Expand|Select|Wrap|Line Numbers
    1. DoCmd.OpenForm "Form2", acNormal, , , acFormEdit, acHidden
    2.  
    3. Forms!Form2![Field3] = "Bart"
    4. Forms!Form2![Field4] = "Simpson"
    5.  
    6. Forms!Form2.Visible = True
  4. As far as retaining Form values once it is closed, how about assigning Field values to a Public Array for later, easy retrieval?
Jun 16 '08 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

2
5807
by: Matt | last post by:
I want to post the form data (http://server/page1.asp) to a modal dialog window (http://server/modaldialog.asp) with a desired height 200px by width 200px. Here's my attempts and problems: Attempt #1) In http://server/page1.asp, it has code <form action="http://server/modaldialog.asp" method="post" target="_blank"> In http://server/modaldialog.asp, it has code <body onBlur = "self.focus()">
2
6521
by: Matt | last post by:
I reposted this question because I really want to accomplish this task. Please advise!! I want to post the form data (http://server/page1.asp) to a modal dialog window (http://server/modaldialog.asp) with a desired height 200px by width 200px. Here's my attempts and problems:
4
1691
by: Job Lot | last post by:
How would I send information from DataGrid on the main form of the application to a modal popup form and then pass any changes to the data back to the main form and database when the popup form was closed? Thanks
2
3884
by: Matt | last post by:
I want to know how to submit the form data to a modal dialog window? The following is page1.asp, and when the user clicks submit button, it will post the form data to page2.asp by opening a new window. But I want modal dialog window, any ideas?? <form action="page2.asp" method="post" target="_blank"> <input type="text" name="username"> <input type="submit" name="submit"> </form>
4
8910
by: Kyralessa | last post by:
In Access 2000, I have a base form with a ListBox of conference registrants. In the form's declarations section I include Dim f as Form To add a registrant I'm doing this: Set f = New Form_frmSingleRegistrant f.Caption = "New Registrant" f.cmdSave.Caption = "&Save New Registrant"
8
1695
by: J. Black | last post by:
Hello everyone - I've been developing an incident tracking and reporting system for an emergency services outfit that I work with part time. It's going well, except for one fly in the ointment. The situation is this - I have a dispatch form that is used by dispatchers to track incidents. An incident number is automatically assigned with an AutoNumber field once a dispatcher initiates an incident by opening the dispatch form. I have...
2
12570
by: Cheryl | last post by:
Hi, I have encounter a problem.Language use is C#. I would like to open a new window (is a modal window, where I m not able to switch from parent window after this window is open)from the parent window , where there are 3 dropdownlists and a "OK" button. Upon clicking the button, this window will close and the select of the dropdownlists will be collect and send back to the parent window. But I am do not know how to do it. Can...
1
7659
by: Curious Trigger | last post by:
Hi there, programming with Visual Studio 2005 and ASP.NET 2.0 I want to open a modal dialog from Default.aspx. I searched the net and many newsgroups but I couldn't find any solution. First I tried using two aspx pages with standard controls and all those post-backs and their attributes OnClientClick. Since this didn't work, i reduced it to a default.aspx page opening a pure html-page as a modal dialog.
7
2212
by: Dan Tallent | last post by:
I have an application I'm working on where one form will open another. This newly opened form needs to return a value based on the users actions. My forms are not modal. I have seen discussions about overridding the DialogResult, however I believe this will only work in a modal form situation. I have code where I've added a custom event to the child form called ReturnValueSet. The form that opens this form can then subscribe to this...
0
9583
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9423
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10039
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9990
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7406
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6668
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5297
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3955
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3560
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.