Go Back   Access World Forums > Microsoft Access Discussion > Forms

 
Reply
 
Thread Tools Rate Thread Display Modes
Old 04-14-2019, 01:53 PM   #1
Hauzz
Newly Registered User
 
Join Date: Oct 2016
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Hauzz is on a distinguished road
Close/hide a form from which another form is opened in acDialog

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

Hauzz is offline   Reply With Quote
Old 04-14-2019, 03:46 PM   #2
essaytee
Need a good one-liner.
 
essaytee's Avatar
 
Join Date: Oct 2008
Location: Melbourne, Australia
Posts: 512
Thanks: 9
Thanked 123 Times in 119 Posts
essaytee is on a distinguished road
Re: Close/hide a form from which another form is opened in acDialog

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
__________________
Steve.

I know UNIX, PASCAL, C, FORTRAN, COBOL, and nineteen other high-tech words.
essaytee is offline   Reply With Quote
Old 04-15-2019, 05:43 AM   #3
MajP
Newly Registered User
 
Join Date: May 2018
Location: USA baby
Posts: 1,567
Thanks: 25
Thanked 470 Times in 447 Posts
MajP will become famous soon enough MajP will become famous soon enough
Re: Close/hide a form from which another form is opened in acDialog

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.

MajP is offline   Reply With Quote
Old 04-15-2019, 07:06 AM   #4
Hauzz
Newly Registered User
 
Join Date: Oct 2016
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Hauzz is on a distinguished road
Re: Close/hide a form from which another form is opened in acDialog

Quote:
Originally Posted by essaytee View Post
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.
Quote:
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 by Hauzz; 04-15-2019 at 08:16 AM.
Hauzz is offline   Reply With Quote
Old 04-15-2019, 07:43 AM   #5
pbaldy
Wino Moderator
 
pbaldy's Avatar
 
Join Date: Aug 2003
Location: Nevada, USA
Posts: 32,791
Thanks: 12
Thanked 4,017 Times in 3,954 Posts
pbaldy is a splendid one to behold pbaldy is a splendid one to behold pbaldy is a splendid one to behold pbaldy is a splendid one to behold pbaldy is a splendid one to behold pbaldy is a splendid one to behold pbaldy is a splendid one to behold
Re: Close/hide a form from which another form is opened in acDialog

Post 4 was moderated, I'm posting to trigger email notifications.
__________________
Paul
Microsoft Access MVP

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
pbaldy is offline   Reply With Quote
Old 04-15-2019, 03:27 PM   #6
essaytee
Need a good one-liner.
 
essaytee's Avatar
 
Join Date: Oct 2008
Location: Melbourne, Australia
Posts: 512
Thanks: 9
Thanked 123 Times in 119 Posts
essaytee is on a distinguished road
Re: Close/hide a form from which another form is opened in acDialog

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).
__________________
Steve.

I know UNIX, PASCAL, C, FORTRAN, COBOL, and nineteen other high-tech words.
essaytee is offline   Reply With Quote
Old 04-16-2019, 01:53 AM   #7
Hauzz
Newly Registered User
 
Join Date: Oct 2016
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Hauzz is on a distinguished road
Re: Close/hide a form from which another form is opened in acDialog

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.
Attached Files
File Type: zip sampledb.zip (979.9 KB, 10 views)


Last edited by Hauzz; 04-16-2019 at 02:35 AM.
Hauzz is offline   Reply With Quote
Old 04-16-2019, 02:24 AM   #8
isladogs
Part time moderator
 
isladogs's Avatar
 
Join Date: Jan 2017
Location: Somerset, UK
Posts: 9,250
Thanks: 105
Thanked 2,487 Times in 2,283 Posts
isladogs is a name known to all isladogs is a name known to all isladogs is a name known to all isladogs is a name known to all isladogs is a name known to all isladogs is a name known to all
Re: Close/hide a form from which another form is opened in acDialog

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/c...ace/4594365418 or https://www.access-programmers.co.uk...d.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.
Attached Files
File Type: zip SetWindows - v3.3.zip (290.2 KB, 8 views)

__________________
If this answer has helped, please click the Thanks button and/or click the 'reputation scales' symbol on the left.

Website links:
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
,
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
,
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
,
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.


Colin
Access 2010 32-bit, Access 2016 32-bit & 64-bit, SQL Server Express 2014, Windows 10,
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
,
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

Last edited by isladogs; 04-16-2019 at 02:51 AM.
isladogs is offline   Reply With Quote
Reply

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
hide controls when a form is opened conditionally jd9913 Forms 4 10-08-2014 10:49 PM
Close form by code that is in AcDialog Window mode? moori Modules & VBA 6 04-13-2012 06:01 AM
[SOLVED] Close form and update a field in an already opened form IDTaylor Forms 0 06-06-2003 12:52 AM
Check if a form is opened/close all forms Doppenberg Modules & VBA 6 05-25-2000 06:48 AM




All times are GMT -8. The time now is 03:29 AM.


Microsoft Access Help
General
Tables
Queries
Forms
Reports
Macros
Modules & VBA
Theory & Practice
Access FAQs
Code Repository
Sample Databases
Video Tutorials

Featured Forum post


Sponsored Links


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
(c) copyright 2017 Access World