Close/hide a form from which another form is opened in acDialog (1 Viewer)

Hauzz

New member
Local time
Today, 16:33
Joined
Oct 13, 2016
Messages
5
I have been trying for a few days to get something done and I just don't succeed.

I make my Access database look like a normal application to the user, which means that the application window of Access is hidden, only the forms are visible.
Therefor all the forms that I use are pop-ups but not modal.

I have a "Customer Search" form, when I click on a customer name another form "Input" opens. This form has a sub form where user enters data.
I open the "Input" form as acWindowNormal and close the "CustomerSearch" form to avoid mistaken clicks on that form.
So far everything is fine, what I expect happens, but now I want the user to be able to start input data immediately, without clicking, and that gives me a problem.
It looks like the focus is in the desired field but I see the main form's title is greyed out and I dont see the cursor in the disered field.When I open the form in acDialog mode, the cursor is visible but then the following problem occurs, the "Customer Search" form then remains open and cannot be closed or hidden.

How can I get the focus on the field in the sub form and still be able to close the form "CustomerSearch"?

Regards,
Hans
 

essaytee

Need a good one-liner.
Local time
Tomorrow, 02:33
Joined
Oct 20, 2008
Messages
512
When you open a form as acDialog (from your Customer Search form) all code execution halts following the DoCmd.OpenForm line, until you close the form that was opened. Under this scenario, it is not possible for the user to inadvertently click any buttons on the Customer Search form, so no need to close it for that reason.

The question is, when opening the form in Dialog mode, are you able to enter data as expected?

As to why not being able to enter data into the form when opened in normal fashion I can't explain that at the moment other than check form settings (Data Entry Y/N, Recordset type, Read Only) (haven't got Access open at the moment for some of the correct terms to use).

I would re-think opening forms as popups by default, that can cause all sorts of nightmares down the track.


Edit:
In the form load or open event, code as follows:
Code:
[Forms]![FormName].[SubFormName].[Form].[ControlName].SetFocus
 

MajP

You've got your good things, and you've got mine.
Local time
Today, 11:33
Joined
May 21, 2018
Messages
8,463
you could put the code in the on load of your form to check if the search form is loaded and if so close it.
 

Hauzz

New member
Local time
Today, 16:33
Joined
Oct 13, 2016
Messages
5
The question is, when opening the form in Dialog mode, are you able to enter data as expected?
Yes, in both acNormal and acDialog I can enter data.
I would re-think opening forms as popups by default, that can cause all sorts of nightmares down the track.
Since the Access application window is hidden, I need all forms to be pop-ups otherwise they wouldn't show.

When I open the form in acDialog, the correct control already has the focus because of the tab order so I don't have to use code for that. I can start entering data immediately without clicking and that's exactly what I want. The only thing I cannot do is close the underlying form.
When I open the form in acNormal, the correct control also appears to have the focus but I don't see the cursor and I can't enter data without clicking on the form first. The text in the title bar of the main form is greyed out so it seems the form isn't active until I click on it. The underlying form closes as I want it to do.
Code:
[Forms]![FormName].[SubFormName].[Form].[ControlName].SetFocus
This code to put the focus on the control I have tried in various ways and it does not give me the result I want.
 
Last edited:

pbaldy

Wino Moderator
Staff member
Local time
Today, 08:33
Joined
Aug 30, 2003
Messages
36,118
Post 4 was moderated, I'm posting to trigger email notifications.
 

essaytee

Need a good one-liner.
Local time
Tomorrow, 02:33
Joined
Oct 20, 2008
Messages
512
I can't replicate what you are reporting. I created two bound forms and initially set the 'Popup' property to Yes. From Form1 opened Form2 in both normal and dialog mode:
Code:
    DoCmd.OpenForm "frm_Form2", acNormal, , , , acWindowNormal
    DoCmd.OpenForm "frm_Form2", acNormal, , , , acDialog
In all tests the opening form received the focus, Form2 title bar NOT greyed out and was able to enter data.

At the Property Sheet of the forms, changing the PopUp to 'No' made no difference, the result was the same.

Something else must be going on with your setup. If possible, can you upload a sample (strip out unnecessary tables, data, reports etc).
 

Hauzz

New member
Local time
Today, 16:33
Joined
Oct 13, 2016
Messages
5
Attached is the sample database. I've packed it with winrar but had to change the extension to zip.
This database is for a store in secondhand clothes for women where people can bring in their used clothes.

There are only 2 customers, the first one already has brought her clothes and the second did not. Click on "New Input" an then on the name of the first customer. The form that is showing, opensed as acNormal. The tile is greyed out and the cursor is not showing in the sub form on the right. When you click the form, it seems like the form becomes active and the cursor is showing in the sub form. When you move the form, you'll see that it is the only form that is open.
Close this form by clicking on "Sluiten". Now click again on "New Input" and select the second customer. The form now showing is opened as acDialog, the title is black, the cursor is showing in the sub form and the user can start immediately working without an extra click. When you move the form, you'll see that the underlying form is still open and, although I know it can't be closed because the form on top is opened in acDialog, that's what I don't want.
I hope I've made myself clear and someone knows what I'm doing wrong.


PS. It is a split database. Put the tree files of the zip file in the same folder then the linking of the tables should go automatically.
 

Attachments

  • sampledb.zip
    979.9 KB · Views: 116
Last edited:

isladogs

MVP / VIP
Local time
Today, 15:33
Joined
Jan 14, 2017
Messages
18,186
Your post was moderated - now approved
Unfortunately your attachment seems to be an invalid zip file.

Have a look at the example application attached.
It is designed to show how the application window can be hidden but still offer full functionality.
So it is similar to your setup I believe

The main form is a popup.
Click the 'OpenFormQuery' button to open another popup form with application window still hidden. The form is immediately editable should you wish to do so.

For more info on this example app, see http://www.mendipdatasystems.co.uk/control-application-interface/4594365418 or https://www.access-programmers.co.uk/forums/showthread.php?t=293584

UPDATE:
I have now managed to open your file using Windows Explorer rather than WinZip.
Unfortunately I can't easily follow what you are doing & don't really have the time to study it properly
It would have helped if you had removed all irrelevant objects / code so we could just focus on the issue you're having

However when I moved the second form as instructed, the underlying form was NOT visible whether the second form was opened normally (first customer or using acDialog (second customer). In both cases the second form now opens without having the focus but that may be due to me changing the tab order whilst experimenting.

Sorry I can't help. Hopefully my example will be useful to you anyway.
 

Attachments

  • SetWindows - v3.3.zip
    290.2 KB · Views: 109
Last edited:

Users who are viewing this thread

Top Bottom