This is a complicated one...
I have a modal form that lets the user preview some text, then either click Submit or Close. This form is called from several other forms.
What I would like, since Access can't return a value from a form, is to set (from the modal form) a hidden checkbox on the calling form, which would show which button the user pressed on the modal form.
My problem is this -- how can I pass the name of the calling form (which may be a subform) to the modal form, so I can set the checkbox on the calling form.
I've thought to just pass Me.Name, and then in the modal form, using Forms(Me.OpenAr gs).chkRetval.. . but when calling from a subform, that fails. I've also considered setting a flag on the modal form, hiding it, reading the flag from the calling form and then closing the modal form, but that seems messy, so it's a last resort.
Any thoughts?
Thanks
11 7005 JKing 1,206
Recognized Expert Top Contributor
I'm a little confused as why you would need to capture which button has been clicked? Why not just add the relevant code to the onclick of the button rather than perform the actions from another forms module?
I'm a little confused as why you would need to capture which button has been clicked? Why not just add the relevant code to the onclick of the button rather than perform the actions from another forms module?
This form allows the user to preview some text before writing it out to another database. I need to know if the user published the text or closed the form without publishing. Based on that, the calling form will either update a "published date" or not. It's a lot cleaner if the calling form takes care of writing that date, instead of the modal form because the published date will not always be in the same table.
JKing 1,206
Recognized Expert Top Contributor
What about a message box with a yes or no button. You can capture which button is pressed and act accordingly.
What about a message box with a yes or no button. You can capture which button is pressed and act accordingly.
The text will typically be too much for a msgbox. Plus, the user wants to be able to edit the text in the preview window.. which means it isn't actually a preview anymore, but the changes made won't be reflected in the local database -- just pushed to the sql server.
It's a complicated thing.
JKing 1,206
Recognized Expert Top Contributor
How about creating a global string variable. On submit click the "preview"te xt is stored in the string on close click the string is set to "".
Then the other form can check the string if it's null do nothing, if its not null send the text to the appropriate location.
I try to avoid global vars at all costs in Access.. I hate them almost as much as Goto's.. hehe
I think I'll just go with my Plan B until a better idea comes along.. on clicking either button, set a hidden flag on the modal form, hide the form, read the flag from the calling form and then close the modal form.
Thanks for the replies.
Denburt 1,356
Recognized Expert Top Contributor
If I understand correctly I have utilized something similar in the past but i use the tag. When you Open the Modal dialog box insert the calling forms name into the tag. Now you know what form originally called the modal form. When you close the modal form call the modal forms tag like so.
Open the modal form:
Docmd.openform "ModalBtch"
Forms!ModalBtch .Tag = me.name
Then on closing the modal form you specify the button clicked and assign it to the calling forms tag like so.
Forms(me.tag).t ag = "Print"
If I understand correctly I have utilized something similar in the past but i use the tag. When you Open the Modal dialog box insert the calling forms name into the tag. Now you know what form originally called the modal form. When you close the modal form call the modal forms tag like so.
Open the modal form:
Docmd.openform "ModalBtch"
Forms!ModalBtch .Tag = me.name
Then on closing the modal form you specify the button clicked and assign it to the calling forms tag like so.
Forms(me.tag).t ag = "Print"
Thanks for the thought, but (as far as I can figure), this wouldn't work with subforms.. Unless I set the parent form's Tag property, but then I'd need to pass Me.Parent.Name. . this is getting messy.
FishVal 2,653
Recognized Expert Specialist
Thanks for the thought, but (as far as I can figure), this wouldn't work with subforms.. Unless I set the parent form's Tag property, but then I'd need to pass Me.Parent.Name. . this is getting messy.
Hi, there.
This simple code will help you to get reference to Form object by name no matter it was openes as main form or as subform with any possible level of nesting. -
Public Function GetForm(ByVal strFormName As String) As Access.Form
-
-
For Each frm In Forms
-
If frm.Name = strFormName Then
-
Set GetForm = frm
-
Exit Function
-
Else
-
Set GetForm = ScanFormControls(strFormName, frm.Controls)
-
If Not (GetForm Is Nothing) Then Exit Function
-
End If
-
Next
-
-
End Function
-
-
Private Function ScanFormControls(ByVal strFormToFind As String, _
-
ByRef frmControlsToScan As Controls) As Access.Form
-
-
On Error GoTo NextIteration
-
For Each ctrl In frmControlsToScan
-
If TypeName(ctrl) = "SubForm" Then
-
If ctrl.Form.Name = strFormToFind Then
-
Set ScanFormControls = ctrl.Form
-
Exit Function
-
Else
-
Set ScanFormControls = _
-
ScanFormControls(strFormToFind, ctrl.Form.Controls)
-
If Not (ScanFormControls Is Nothing) Then Exit Function
-
End If
-
End If
-
NextIteration:
-
Next
-
-
End Function
-
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Seeker |
last post by:
Newbie question here...
I have a form with some radio buttons. To verify that at least one of the
buttons was chosen I use the following code ("f" is my form object) :
var btnChosen;
for (count = 0; count <= 1; count++) {
if (eval(f.RadioButtons.checked)) {
btnChosen = true;
}
|
by: Vanessa |
last post by:
Hi,
I would like to know whether there's any way for me to pass an object by
reference to another form?
Regards
Vanessa
|
by: Casey |
last post by:
Yeah, I know this question was asked by someone elselike 2 weeks ago. But I
need some additional help. I have a program I'm developing, and multiple
different forms will be opened. For now though, I just have two forms. One is
the main window, and the other sets some preferences like names, and email
addresses.
When someone opens this...
|
by: Mr A |
last post by:
Hi!
I've been thinking about passing parameteras using references instead
of pointers in order to emphasize that the parameter must be an
object.
Exemple:
void func(Objec& object); //object must be an object
instead of
|
by: DCB |
last post by:
Hello.
I have an easy question, likely, that has me in a headspin. I have an
include file to a frames based site that basically forces frames on
the end user if they visit the site and hit a non-frames created
page...
Simply, it is:
if (parent != self)
| |
by: Omar Llanos |
last post by:
Recently, I posted a question on how to invoke a textbox control in Form1
(parent form) from within Form2 (which is inherited from Form1).
Someone suggested to pass a reference of the Form1 to the Form2 through the
constructor of the Form2. He said that then I'd be able to invoke the
textbox control in Form1 (with code in Form2).
Since I'm...
|
by: Vaughn |
last post by:
When I pass a reference to my current form, frm_x, when I create and show
another form, frm_y, do I have access to all of the public methods,
controls, members, etc.. of frm_x from frm_y?
In my code, I pass the reference like this:
private void btn_ListEmp_Click(object sender, System.EventArgs e)
{
frm_EmpList frm_empList = new...
|
by: Chane |
last post by:
hi
i have doubt in how to pass values back to the called
form. I have two forms, each having a textbox and a button
control. First i'm run the first form and click the
button, it creates object for second form and showed as
modaless. And i entered some text in second form's
textbox. While i clicked the seconds form's button the
value in...
|
by: forest demon |
last post by:
all i want is to do is to pass a form reference to a separate class
and be able to manipulate properties/components/controls of said form.
this should be as simple as passing a TextBox, Container object or
something similar, to do the same, but no.
what am i missing, besides my mind?
thanks folks...
|
by: raylopez99 |
last post by:
Keywords: scope resolution, passing classes between parent and child
forms, parameter constructor method, normal constructor, default
constructor, forward reference, sharing classes between forms.
Here is a newbie mistake that I found myself doing (as a newbie), and
that even a master programmer, the guru of this forum, Jon Skeet,
missed!...
|
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...
| |
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...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it. ...
|
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...
|
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...
|
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...
|
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
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...
| |