Results 1 to 11 of 11
  1. #1
    drunyan0824 is offline Advanced Beginner
    Windows 10 Access 2013 64bit
    Join Date
    Jun 2022
    Posts
    82

    Bring a Tabbed Window To Front

    I have a search form in my database where the user enters the sting of data that they would like to search for and when a command button is clicked a form is opened if there are any records in the database that partially match the string of data the was inputted by the user. I have gotten the code to work with one minor problem, in the event of a successful search the form that is opened stays behind the main navigation form.

    This is the code for my search button:

    Code:
    Private Sub btnCableTextSearch_Click()Dim txtSearchCritera As String
    
    
        txtSearchCriteria = "cableSouceDescription Like '*" & Me!txtCableTextSearch & "*'"
    Debug.Print txtSearchCriteria
    
    
    '    txtSearch = DLookup("cableSouceDescription", "tblCableInformation", txtSearchCriteria)
    'Debug.Print txtSearch
        If IsNull(Me.txtCableTextSearch) Then
            MsgBox "Nothing Was Entered", vbOkayOnly, "Invalid Entry"
            txtSearchCriteria = ""
            Me.txtCableTextSearch.SetFocus
        Else
            DoCmd.OpenForm "frmCableInformation", acNormal, , txtSearchCriteria, , acWindowNormal, "Edit"
            txtSearchCriteria = ""
            DoCmd.Close acForm, "frmCableTextSearch", acSaveNo
    End If
    
    
    End Sub
    I can figure out how to set focus on a field on a form, but I can't seem to find a way to control which tabbed window is in front of other tabs.



    It seems like
    Code:
    DoCmd.OpenForm "frmCableInformation", acNormal, , txtSearchCriteria, , acWindowNormal, "Edit"
    Should open the form and make in the top tab in Access.

    What am I missing

    TIA

  2. #2
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,800
    Confusing. Tabbed forms display side by side. I don't think there is such a thing as a tabbed window but I guess that's subject to one's interpretation. If your forms are set to be 'overlapping windows' then open the form modal. That should force it to stay on top, but you will not be able to interact with any other db object until that form is closed. Lastly, a navigation form is another thing altogether so if that's where you're opening this other form then none of that applies.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  3. #3
    davegri's Avatar
    davegri is offline Excess Access
    Windows 11 Access 2019
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,411
    This method works for reports, maybe forms also.

    Code:
    DoCmd.OpenForm "frmCableInformation",acNormal,,txtSearchCriteria,,acWindowNormal, "Edit"
    DoCmd.SelectObject acForm, "frmCableInformation"         'bring to front

  4. #4
    drunyan0824 is offline Advanced Beginner
    Windows 10 Access 2013 64bit
    Join Date
    Jun 2022
    Posts
    82
    Quote Originally Posted by Micron View Post
    Confusing. Tabbed forms display side by side. I don't think there is such a thing as a tabbed window but I guess that's subject to one's interpretation. If your forms are set to be 'overlapping windows' then open the form modal. That should force it to stay on top, but you will not be able to interact with any other db object until that form is closed. Lastly, a navigation form is another thing altogether so if that's where you're opening this other form then none of that applies.
    Sorry for the confusion, I was referring to the tabbed forms that are being displayed from left to right. The forms and my database are not set to be 'Overlapping Windows' and my navigation form is really a collection of command buttons.

    This is the sequence of events that are leading to my current issue:

    One the main cable navigation form, the user would click on a button captioned 'Search By Text' and that would open the search by text form via DoCmd.OpenForm :

    Code:
    Private Sub btnMainFormTextSearch_Click()    
        DoCmd.OpenForm "frmCableTextSearch", acNormal, , , , acWindowNormal
           
        
    End Sub
    After that form is open, the user would enter the text that they want to search the database for and click a button captioned 'Search'. The code that I have for the search button is:

    Code:
    Private Sub btnCableTextSearch_Click()Dim txtSearchCritera As String
    
    
        txtSearchCriteria = "cableSouceDescription Like '*" & Me!txtCableTextSearch & "*'"
    Debug.Print txtSearchCriteria
    
    
        If IsNull(Me.txtCableTextSearch) Then
            MsgBox "Nothing Was Entered", vbOkayOnly, "Invalid Entry"
            txtSearchCriteria = ""
            Me.txtCableTextSearch.SetFocus
        Else
            DoCmd.OpenForm "frmCableInformation", acNormal, , txtSearchCriteria, , acWindowNormal, "Edit"
            txtSearchCriteria = ""
            DoCmd.Close acForm, "frmCableTextSearch", acSaveNo
    End If
    
    
    End Sub
    The form "frmCableInformation" opens and I can see the tab, but the first "navigation" form is still the active tab after "frmCableTextSearch" is closed.

    Where I am getting confused at this that I have another search function that I designed for looking up a cable by an assigned number and I have the DoCmd.OpenForm command structured in the same fashion but I don't experience the same problem.

    Here is the snippet of that code for the search by cable number:
    Code:
            If countRecords > 0 Then
    
                cableNumberCriteria = "cableCategory_PK = " & convertCatString & " And CableNumber = '" & strNumberSplit & "'"
            Debug.Print cableNumberCriteria
            DoCmd.OpenForm "frmCableInformation", acNormal, , cableNumberCriteria, , , "Edit"
    
    
            ElseIf countRecords = 0 Then
                MsgBox "No Matching Cable Number Found", vbOKOnly, "Search By Cable Number"
            End If
    Could this issue be as simple as the fact that in on situation I am opening a form, running a search, then trying to open the form with the search results versus running a search and then just opening the forms that match the search criteria?

  5. #5
    davegri's Avatar
    davegri is offline Excess Access
    Windows 11 Access 2019
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,411
    Quick try:
    Make frmCableInformation a popup form.

  6. #6
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,800
    I was going to suggest that, and also leaving it as is and trying to set the focus to a control on the opened form. That form would then be the active form.
    acWindowNormal opens a form using the mode that is set in its properties. Unfortunately I'm still a bit muddled. You say
    in the event of a successful search the form that is opened stays behind the main navigation form.
    I don't see how this is possible if you're using tabbed documents as you say.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  7. #7
    drunyan0824 is offline Advanced Beginner
    Windows 10 Access 2013 64bit
    Join Date
    Jun 2022
    Posts
    82
    I am sorry. I meant that the form that is opened after a successful search is not the active tab. I can see that the form opened as the tab for the form is just to the right of the tab for the main navigation form, but I have to click on the tab to view the search results.

    I am sorry for the confusion, I keep thinking of the tabs in access in terms of standard Microsoft windows where the active Window usually covers the inactive Windows on my desktop.

  8. #8
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,800
    OK, so the issue is that you're using tabbed forms and can't or don't want to make the form in question as a popup form. You also are not concerned with the tab order of your forms, you just want a particular form be the one that is shown. Then try setting focus to that tabbed form. That is a bit of a misnomer in that you can't actually do that if the form has controls on it, but it will make the tabbed form the 'active' form. The last control to have the focus is what will actually have the focus.

    I had to switch back to tabbed forms to make sense of this 'behind' and 'in front' stuff. Now I get it, so sorry about that. I'm reminded that it does resemble a behind/in front sort of thing.

    EDIT - so like Forms!myFormNameHere.SetFocus
    Not sure where you'd need to put that.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  9. #9
    drunyan0824 is offline Advanced Beginner
    Windows 10 Access 2013 64bit
    Join Date
    Jun 2022
    Posts
    82
    Quote Originally Posted by Micron View Post
    OK, so the issue is that you're using tabbed forms and can't or don't want to make the form in question as a popup form. You also are not concerned with the tab order of your forms, you just want a particular form be the one that is shown. Then try setting focus to that tabbed form. That is a bit of a misnomer in that you can't actually do that if the form has controls on it, but it will make the tabbed form the 'active' form. The last control to have the focus is what will actually have the focus.

    I had to switch back to tabbed forms to make sense of this 'behind' and 'in front' stuff. Now I get it, so sorry about that. I'm reminded that it does resemble a behind/in front sort of thing.

    EDIT - so like Forms!myFormNameHere.SetFocus
    Not sure where you'd need to put that.
    I've found that putting Forms!myFormNameHere.SetFocus after the DoCmd.OpenForm command solves the problems that I am having. But it is funny you mention making the forms in question pop up. Initially I was trying to make these forms popup, but I kept running into this weird issue where after making some changes to the forms that Access would lock up when I tried to open the forms and I couldn't figure out what I did. Even after changing the forms back to the Single forms access would still lock up. Eventually I just had to remake the forms.

  10. #10
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,800
    Sometimes forms do get corrupted and the only way to fix is to recreate. I didn't see anything in your posts that suggested corruption though. Seems like you have a solution now. If so, maybe mark your thread as solved?
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  11. #11
    drunyan0824 is offline Advanced Beginner
    Windows 10 Access 2013 64bit
    Join Date
    Jun 2022
    Posts
    82
    Once I recreated the forms it wasn't an issue for me anymore, I may try to change the forms back to pop ups but I will mark this thread solved.

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

Similar Threads

  1. Bring the Access-window to the front ??
    By ksor in forum Programming
    Replies: 3
    Last Post: 07-16-2018, 01:11 PM
  2. Access 2016 won't bring up front end
    By EScottHug in forum Access
    Replies: 1
    Last Post: 06-29-2016, 03:02 PM
  3. Replies: 2
    Last Post: 12-23-2015, 09:32 PM
  4. Text box width/bring to front and Checkbox
    By SorenIX in forum Programming
    Replies: 16
    Last Post: 06-22-2011, 06:07 PM
  5. Replies: 2
    Last Post: 03-28-2010, 04:15 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