Results 1 to 11 of 11
  1. #1
    Robyn_P's Avatar
    Robyn_P is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    Nov 2017
    Posts
    150

    open form command being hit but not opening form


    Hi all,

    I was wondering if any of you could see what is wrong with this code? The line DoCmd.OpenForm "frmOutstandingReviews" is being hit but it isn't opening the form. Is it because I open another form directly afterwards?

    What I'm aiming for is if someone still has work to do the form pops up to tell them before the main dashboard opens, but it just won't open.

    Hope that's clear, I don't get any error message, just nothing happens

    Code:
    Private Sub cmdLogin_Click()
    
        Dim DashboardPic As String
        Dim rs As DAO.Recordset
    
    
        'Check that both a username and password have been added
        If IsNull(Me.txtPassword) Or IsNull(Me.cboUserName) Then
            MsgBox "You must enter both a username and password", vbOKOnly, "Missing Data"
            Exit Sub
        End If
        
        'Check the User's Password matches that in the users table
        If Me.txtPassword.Value <> DLookup("Password", "tblUsers", _
            "[ID]=" & Me.cboUserName.Value) Then
            
            ' Inform the user of an incorrect password and close
            MsgBox "Password Invalid.  Please try again", vbOKOnly, "Invalid Entry"
            Me.txtPassword.SetFocus
            Exit Sub
    
    
        End If
       
                         
        'Check whether the user has any outstanding IPS plans or procedures to review
        ' If so, pop up the outstanding reviews form.
        Set rs = CurrentDb.OpenRecordset("SELECT * FROM tblIPScomments WHERE [MainReviewer]=" & Me.cboUserName)
        If Not (rs.BOF And rs.EOF) Then
            DoCmd.OpenForm "frmOutstandingReviews"
        Else
            ' No outstanding IPS plans but there may be outstanding procedures so check this
            Set rs = CurrentDb.OpenRecordset("SELECT * FROM tblProcComments WHERE [PrimaryReviewer]=" & Me.cboUserName)
            If Not (rs.BOF And rs.EOF) Then
                DoCmd.OpenForm "frmOutstandingReviews"
            End If
        End If
        
        rs.Close
        Set rs = Nothing
        
            
        ' Open frmDashboard The On Open even of frmDashboard takes the userID from
        ' This form and saves it for furture reference on frmDashboard
        DoCmd.OpenForm "frmDashboard"
        
        ' Close this form
        DoCmd.Close acForm, "frmLogin", acSaveNo
          
    End Sub

  2. #2
    Robyn_P's Avatar
    Robyn_P is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    Nov 2017
    Posts
    150
    Just an update on what I have tried so far.

    1: Specifying open in acPreview mode - for opens but in preview mode on a tab, looks like a report, this is not what I want but it does open
    2: Specifying open in acNormal mode - nothing happens, form does not open
    3: Compact and repair database, twice
    4: Moving the code to the onload event of the dashboard form - again the line of code to open the form is hit, but the form doesn't open

  3. #3
    davegri's Avatar
    davegri is online now Excess Access
    Windows 10 Access 2019
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,413
    Try this:

    Code:
    If Not (rs.BOF Or rs.EOF) Then

  4. #4
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,938
    Personally I only ever use EOF when opening a recordset.
    So you are saying you are getting to that line, and it is not be executed?
    You are walking the code line by line after setting a breakpoint?
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  5. #5
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,430
    why not just use dcount


    If dcount("*", "tblIPScomments","[MainReviewer]=" & Me.cboUserName & " OR [PrimaryReviewer]=" & Me.cboUserName)>0 then DoCmd.OpenForm "frmOutstandingReviews"

  6. #6
    Robyn_P's Avatar
    Robyn_P is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    Nov 2017
    Posts
    150
    Hi All,

    Sorry I wasn't clear. The logic statements are working fine, when I step through the code, I see it go to the docmd.openform line, but the form doesn't open.

    I'm going to try recreating the form next I think

  7. #7
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,938
    Just try another form as a test?
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  8. #8
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,430
    I was just suggesting simpler code and combining the criteria so you only needed one line rather than eleven.

    but if you have stepped through then assuming the formname is correct it should be opening - I presume the form is popup and modal otherwise it might be opening behind another form.

    You could try opening with acDialog.

    Also it is possible for a form to open 'off screen' if you have multiple monitors and have changed their setting

  9. #9
    Robyn_P's Avatar
    Robyn_P is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    Nov 2017
    Posts
    150
    Quote Originally Posted by CJ_London View Post
    I was just suggesting simpler code and combining the criteria so you only needed one line rather than eleven.

    but if you have stepped through then assuming the formname is correct it should be opening - I presume the form is popup and modal otherwise it might be opening behind another form.

    You could try opening with acDialog.

    Also it is possible for a form to open 'off screen' if you have multiple monitors and have changed their setting

    Ahh I see, okay I may try simplifing the code, i agree that it's not the smoothest bit of coding.
    I hadn't thought about the off screen thing, I'll turn on the autocentre property of the form and see if that makes a difference.
    I don't want it to open AC dialogue and I want the dashboard to open as well, but thanks for the suggestion.

    All good ideas, will try and get back to you. Thanks

  10. #10
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,430
    was suggesting acdialog as a test to force the form to be on top - would eliminate one of the reasons for the form not appearing

  11. #11
    Robyn_P's Avatar
    Robyn_P is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    Nov 2017
    Posts
    150
    Just opened the database on the big screen at work and everything worked fine. Think it must have been opening on a phantom screen?

    Thanks for all the suggestions

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

Similar Threads

  1. Replies: 3
    Last Post: 03-30-2021, 10:28 AM
  2. Opening Outside Form Using Command Button: VBA
    By tlkng1 in forum Programming
    Replies: 3
    Last Post: 06-16-2017, 09:25 AM
  3. Replies: 5
    Last Post: 10-18-2016, 06:00 AM
  4. Opening a report from a form command
    By undee69 in forum Reports
    Replies: 4
    Last Post: 01-13-2013, 08:57 AM
  5. Replies: 2
    Last Post: 05-11-2012, 11:52 AM

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