View Full Version : MsgBoxes not showing up
maxtin
12-06-2008, 11:39 AM
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 :doh:
Oorang
12-10-2008, 08:16 AM
Are you perchance supressing errors with "On Error Resume Next"?
maxtin
12-10-2008, 02:14 PM
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
Oorang
12-10-2008, 06:40 PM
Wow that is odd. Can you post the whole procedure?
maxtin
12-11-2008, 11:37 AM
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
Oorang
12-11-2008, 12:08 PM
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.
CreganTur
12-12-2008, 08:54 AM
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).
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?
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.