Results 1 to 7 of 7
  1. #1
    cebrower is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2018
    Location
    Spring Lake, MI
    Posts
    110

    Wrong form comes to the front


    I have a pop-up form named frmMainMenu that opens maximized. If the user clicks the Start New Order button, a pop-up form opens showing our customer table in datasheet view, not maximized. The user double clicks the name of the customer he wants and a pop-up form named frmOrderEntry opens maximized. In the Load event, several non-pop-up forms open and close so certain information can be read from them to unbound fields on frmOrderEntry, for example, the customer’s credit limit, outstanding balance, etc. My problem is that occasionally, after all the data has been read, frmOrderEntry is no longer on top of the other open forms. Oddly, if the user presses ctrl-alt-del, starts Task Manager and then closes it, frmOrderEntry comes to the front. I’ve tried SetFocus and SelectObject to bring frmOrderEntry to the front, but neither works. I’ve also tried changing frmOrderEntry to Data Entry mode with no success.

    My users are all using the run-time version of Access 2010 and running the front end in ACCDE format, but the same issue exists using the full version of Access 2010 with the front end in ADDDB format. Has anyone else experienced this issue? I would appreciate any suggestions.

  2. #2
    Micron is online now Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,737
    Don't use more than one popup at a time, or this is what you'll get. Instead, hide the earlier form if there is an order like A - B - C then backwards close C, show B, close B show A. A subsequent form can also inherit a size based on the previously opened form (e.g. maximized or restored) but not usually if they're popups. The main problem with Access and popups is that Access doesn't deal with the Z order of windows. The effort required to work with the form window handles isn't worth it IMHO, but you could research API calls for window handles, but I wouldn't bother.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  3. #3
    cebrower is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2018
    Location
    Spring Lake, MI
    Posts
    110
    Thank you Micron. I'll make some changes based on your advice.

  4. #4
    ssanfu is offline Master of Nothing
    Windows 7 32bit Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    Quote Originally Posted by cebrower View Post
    I have a pop-up form named frmMainMenu that opens maximized. If the user clicks the Start New Order button, a pop-up form opens showing our customer table in datasheet view, not maximized. The user double clicks the name of the customer he wants and a pop-up form named frmOrderEntry opens maximized. In the Load event, several non-pop-up forms open and close so certain information can be read from them to unbound fields on frmOrderEntry, for example, the customer’s credit limit, outstanding balance, etc.
    That is a very convoluted method to start a new order and get data for the customer.
    You open a form in datasheet mode to select a customer?? Why don't you just use an unbound combo box or list box to select the customer? Once you have the PK of the customer, code can get the customer’s credit limit, outstanding balance, etc.. You wouldn't be opening and closing all of those forms.

    Or the "New Order Form" record source is a query/SQL string that has every customer and their data - you (set a filter) select a customer and enter the new order in the sub form.



    My $0.02 ...........

  5. #5
    cebrower is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2018
    Location
    Spring Lake, MI
    Posts
    110
    Thanks for the advice ssnafu. We have >500 customers, many with multiple locations. We have >700 products sold in >10 types of containers. Customers often place orders to be delivered at addresses different than their physical address (job sites). When your products are live plants in various stages of growth and your customers are landscapers and garden centers it becomes a little more complex than grabbing widgets off a shelf. Our order entry system works very well and our staff loves it. But once in a while the wrong form comes to the front. When I have a little time I'll try Micron's advice.

  6. #6
    Micron is online now Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,737
    Uglier perhaps, but you could entertain the idea of tabbed view for forms. However, it propagates to all forms and reports. You can't have some tabbed and others not.

  7. #7
    accesstos's Avatar
    accesstos is offline Expert
    Windows XP Access 2007
    Join Date
    Dec 2018
    Location
    Greece
    Posts
    551
    Maybe, this tiny API function is all that you need:
    Code:
    Public Declare Function SetForegroundWindow Lib "user32" (ByVal hwnd As Long) As Long
    Put it in a standard code module and then you can use it as follows:
    Code:
    SetForegroundWindow forms!frmOrderEntry.hwnd
    I hope it helps!

Please reply to this thread with any new information or opinions.

Similar Threads

  1. What is wrong with the form?
    By Lou_Reed in forum Access
    Replies: 14
    Last Post: 04-27-2017, 12:21 PM
  2. VBA for search form - SQL wrong ?
    By Lukael in forum Programming
    Replies: 4
    Last Post: 02-04-2016, 12:44 AM
  3. Form Calculation is wrong!
    By Lou_Reed in forum Access
    Replies: 32
    Last Post: 08-04-2015, 02:16 PM
  4. Form opens in wrong view
    By gar in forum Forms
    Replies: 3
    Last Post: 07-10-2015, 12:47 AM
  5. Can not refresh a form - what am I doing wrong?
    By RedGoneWILD in forum Forms
    Replies: 9
    Last Post: 06-26-2012, 04:53 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums