Consulting

Results 1 to 8 of 8

Thread: MsgBoxes not showing up

  1. #1

    MsgBoxes not showing up

    Hi, i have this very strange problem that occurs SOMETIMES with a software where you can use vba code.

    When i run the code, msgboxes fail to show up and code is continuing through. I use this software (called RSView32 from Rockwell Automation) since couple of years now, and this is the first time i see this problem. The fix is simply by restarting the application but this is very annoying since msgboxes of type vbYesNo are getting "1 (vbOk)" automatically then the code continue on (like if someone acknowledged it). After I restart the application, it works fine for a while (msgboxes are popping normally) and then (seems randomly) you dont see them popping anymore.

    I have two types of msgboxes in my code and both are affected:

    1. Msgbox msg

    2. Response = MsgBox(Msg, Style, Title, Help, Ctxt)


    Anyone already saw/experienced this?

    help please...i really need to solve this

  2. #2
    Knowledge Base Approver VBAX Master Oorang's Avatar
    Joined
    Jan 2007
    Posts
    1,135
    Location
    Are you perchance supressing errors with "On Error Resume Next"?
    Cordially,
    Aaron



    Keep Our Board Clean!
    • Please Mark your thread "Solved" if you get an acceptable response (under thread tools).
    • Enclose your code in VBA tags then it will be formatted as per the VBIDE to improve readability.

  3. #3
    Quote Originally Posted by Oorang
    Are you perchance supressing errors with "On Error Resume Next"?
    not at all

    Private Sub Test()
    
    On Error Goto Error
    
     MsgBox "test"
    
     exit sub
    
    Error:
    
     MsgBox "Error occured"
    
    End Sub

  4. #4
    Knowledge Base Approver VBAX Master Oorang's Avatar
    Joined
    Jan 2007
    Posts
    1,135
    Location
    Wow that is odd. Can you post the whole procedure?
    Cordially,
    Aaron



    Keep Our Board Clean!
    • Please Mark your thread "Solved" if you get an acceptable response (under thread tools).
    • Enclose your code in VBA tags then it will be formatted as per the VBIDE to improve readability.

  5. #5
    Private Sub Compare(ByVal SQLString As String, ByVal SQLString2 As String)
     
    On Error GoTo error
     
       Dim cnDATA As ADODB.Connection
       Dim rsDATA2 As ADODB.Recordset
       Dim strConn As String
       Set cnDATA = New ADODB.Connection
     
       Dim QuestionMsg
     
     
    If DtbConnError = False Then
       strConn = "PROVIDER=SQLOLEDB;"
       strConn = strConn & " DATA SOURCE= " & conDataSource & ";INITIAL CATALOG=" & conInitialCatalog & ";"
       strConn = strConn & " USER ID=" & conUserID & "; PASSWORD=" & conPassword
     
     cnDATA.Open strConn
     
    End If
     
     
       Dim TagCol As Tags
       Dim temp As String
     
     
       Set TagCol = gTagDb.QueryForTags("TAG*", roIncludeAnalog)
     
       TagCol.ScanOn roWait
     
       Dim i As Single
          If Me.txtQty.Text <> "" Then
     
            i = CSng(Me.txtQty.Text)
     
            If i <> 0 Then
     
                'check if connection available
                If DtbConnError = False Then
     
                    If Me.cmbIng.Text <> "" Then
     
                       Set rsDATA = New ADODB.Recordset
     
                        With rsDATA
                       .ActiveConnection = cnDATA
                       .Open SQLString
                        End With
     
                       If Not (IsNull(rsDATA("NumKey"))) Then
     
                         Dim HIng As Integer
                         HIng = TagCol.Item("TAG").Value
     
                            If HIng <> rsDATA("NumKey") Then
     
     
                                Set rsDATA2 = New ADODB.Recordset
     
                                With rsDATA2
                                     .ActiveConnection = cnDATA
     
                                     .Open SQLString2                                 
                                End With
     
                                     If IsNull(rsDATA2("Name")) Or rsDATA2.EOF = True Then
                                         temp = "unknown"
                                     Else
                                         temp = rsDATA2("Name")
                                     End If
     
                                     QuestionMsg = MsgBox("Are you sure?", vbYesNo, "Warning")
     
                                     Select Case QuestionMsg
                                         Case vbYes
                                          TagCol.Item("TAG").PendingValue = rsDATA("NumKey")
                                    End Select
     
     
                             End If
     
                         End If
                   End If
               End If
          End If
       End If
     
     Exit Sub
     
    Error:
     MsgBox "Error"
    End Sub

  6. #6
    Knowledge Base Approver VBAX Master Oorang's Avatar
    Joined
    Jan 2007
    Posts
    1,135
    Location
    Here is what I would do. I notice not all logic paths lead to a msgbox. I would put debug.print statements in each path to see what path was followed when a box does not appear. Or in the alternative use stops/breakpoints so you can see what condition caused the alternation.
    Cordially,
    Aaron



    Keep Our Board Clean!
    • Please Mark your thread "Solved" if you get an acceptable response (under thread tools).
    • Enclose your code in VBA tags then it will be formatted as per the VBIDE to improve readability.

  7. #7
    VBAX Master CreganTur's Avatar
    Joined
    Jan 2008
    Location
    Greensboro, NC
    Posts
    1,676
    Location
    I agree with Aaron.

    Take a careful look at your code. You only have a single MsgBox command and it is nested within your deepest If statement. In order to even get to your MsgBox every single conditional will have to pass. If one of them fails, then you won't continue deeper into the nested If's, therefore you won't reach the message box.

    If every outcome of every if statement (pass and fail) should result in a MsgBox being fired, then you are going to need to add additional MsgBox's (or if they all call the same one, setup a Call so you don't have to write them all in by hand every time).
    -Randy Shea
    I'm a programmer, but I'm also pro-grammar!
    If your issue is resolved, please use Thread Tools to mark your thread as Solved!

    PODA (Professional Office Developers Association) | Certifiable | MOS: Access 2003


  8. #8
    VBAX Newbie
    Joined
    Feb 2012
    Posts
    1
    Location
    Hello,
    I have got a problem with a msgbox that does not whow up.
    I am a newbie here, so I don't know if it works to take up a thread like this.
    As suggested in this thread, I have added a debug.print -line with the same content as the Msgbox-line (which is right after with nothing in between). The debug-line is displayed in the I-window, but the Msgbox is not showing up.
    The strange thing is that Msgboxes further down n the programme show up. Would you have any idea of what could be wrong?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •